Morten Snedker wrote:
In another thread I found this snippet for validating an e-mail:
^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$
I think this actually has a few bugs. This is what it matches:
<regex description>
One or more characters that are each a letter or a digit or _ or - or .
Then @
Then
Either [ followed by a 'dotted triple', being three 1 to 3 digit
numbers each followed by .
Or one or more instances of (a 'word' followed by .), where the 'word's
'letters' can be letters or digits or -
Then
Either 2 to 4 letters
Or a 1 to 3 digit number
Then optionally ]
Furthermore, there must be no characters in the string before or after
the characters that match the above pattern.
</regex description>
The bug? Well, presumably the intention is to allow the 'server' part
of the address to be either @[aaa.bbb.ccc.ddd] (with acceptable
numbers) or @word.anotherwo rd.domain (with letters) - but as it stands,
all these things will be matched:
us**@word.anotherword.123
us**@word.anotherword.123]
us**@123.456.78 9.com
user@[999.999.999.999
user@[999.999.999.999]
none of which look as if they will be valid.
But it's a sticky area to get in to, frankly, so I'm not gonna make too
much of a fuss :)
--
Larry Lard
Replies to group please