[Rets-dev] Email validation regular expression
Paul Stusiak
pstusiak at falcontechnologies.com
Wed Apr 25 16:51:41 CDT 2007
I think that the one that is in place already is sufficiently ugly :-)
Also, several of the validation libraries cannot handle characters
escaped in the fashion below or understand \w or \d. You need to use the
entity values. You've got to love half baked solutions where only a
portion of the reg ex can be expressed - sigh. It would be really nice
if there was a standard regular expression language that was used by
everyone, but there isn't (never mind the i18n quagmire).
Paul
Matt Lavallee wrote:
> Alright, here we go:
> ^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`
> \{\|\}(\\\@)\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.
> )+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2
> [0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$
>
> I think that's ugly enough. ;)
>
> -Matt
>
>
>> -----Original Message-----
>> From: Paul Stusiak [mailto:pstusiak at falcontechnologies.com]
>> Sent: Wednesday, April 25, 2007 4:07 PM
>> To: Matt Lavallee
>> Cc: rets-dev at rets.org
>> Subject: Re: [Rets-dev] Email validation regular expression
>>
>> Thank you for the suggestion.
>>
>> Your suggestion does not validate the following valid email addresses:
>>
>> !def!xyz%abc at local.example.com
>> a.one_two{}@some.example.com
>> a.one_two at some.example.com
>> some\@one at example.com
>>
>> which was tested using the on-line regex testing tool
>> http://www.fileformat.info/tool/regex.htm
>>
>> A good location for regular expressions is here
>> http://regexlib.com/
>>
>> search for email. There is grading (use with caution, the results don't
>> always match the grade...)
>>
>> This is where the root of the regex came from that is in the Phone.xsd.
>> I've also seen regular expressions that enumerate the possible top level
>> domains - this strikes me as a bad thing for a standard since the
>> addition of new top level domains which happens on a regular basis,
>> would require a change to the schema.
>>
>> Also note that xsd do not use the '^' and '$' to indicate the start and
>> end of line.
>>
>> As noted in the schema, the patterned used does not cover all cases, but
>> does cover the first three above but not the some\@one at example.com
>> pattern where reserved characters are escaped. It didn't seem necessary
>> to me.
>>
>>
[snip]
--
Paul Stusiak
Falcon Technologies Corp.
More information about the Rets-dev
mailing list