My understanding of regular expressions is rudimentary,
at best.
I have this RegExp to to a very simple validation of an
email-address, but it turns out that it refuses to
accept mail-addresses with hypens in them.
Van anybody please help me adjust it so it will accept
addresses like dag-sunde@test-domain.net too?
Here's what got:
function validateEmail(eMail) {
return /^(\w+\.)*(\w+)@(\w+\.)+([a-zA-Z]{2,4})$/.test(eMail);
}
TIA...

Signature
Dag.
Work is the curse of the drinking classes
-- Oscar Wilde
Dag Sunde - 03 Nov 2005 10:38 GMT
> My understanding of regular expressions is rudimentary,
> at best.
[quoted text clipped - 11 lines]
> return /^(\w+\.)*(\w+)@(\w+\.)+([a-zA-Z]{2,4})$/.test(eMail);
> }
Ooops!
Sorry, I really meant to post this to c.l.javascript, not java...
(But if anyone know the answer...)

Signature
Dag.
carlos@gkpwdun.com - 03 Nov 2005 11:41 GMT
>> My understanding of regular expressions is rudimentary,
>> at best.
[quoted text clipped - 11 lines]
>> return /^(\w+\.)*(\w+)@(\w+\.)+([a-zA-Z]{2,4})$/.test(eMail);
>> }
return /^[\w.+-]+@[\w.+-]+\.[\w]{2,7}/.test(eMail);
Roedy Green - 03 Nov 2005 12:19 GMT
> return /^(\w+\.)*(\w+)@(\w+\.)+([a-zA-Z]{2,4})$/.test(eMail);
see http://mindprod.com/jgloss/regex.html. have a look at what \w is
short for, and use that expansion slightly modified.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Dag Sunde - 03 Nov 2005 13:25 GMT
> My understanding of regular expressions is rudimentary,
> at best.
[quoted text clipped - 5 lines]
> Van anybody please help me adjust it so it will accept
> addresses like dag-sunde@test-domain.net too?
Thank you all!
I ended up with thisone (wraps):
function validateEmail(eMail) {
return
/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/.test(eMail);
}

Signature
Dag.