Matthew Smillie
1/4/2006 1:15:00 PM
On Jan 4, 2006, at 12:47, Andreas S. wrote:
> Jacob Fugal wrote:
>> On 1/3/06, Dan Kohn <dan@dankohn.com> wrote:
>>> Here's a rails example for validating email addresses.
>>>
>>> validates_format_of :login, :with => /
>>> ^[-^!$#%&'*+\/=?`{|}~.\w]+
>>> @[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])*
>>> (\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])*)+$/x,
>>> :message => "must be a valid email address",
>>> :on => :create
>>
>> Be careful with email validation via regex, it's harder than you
>> might
>> think[1][2]:
>>
>> /^([a-zA-Z0-9&_?\/`!|#*$^%=~{}+'-]+|"([\x00-\x0C\x0E-\x21\x23-\x5B
>> \x5D
>> -\x7F]|\\[\x00-\x7F])*")(\.([a-zA-Z0-9&_?\/`!|#*$^%=~{}+'-]
>> +|"([\x00->> x0C\x0E-\x21\x23-\x5B\x5D-\x7F]|\\[\x00-\x7F])*"))*@([a-zA-Z0-9&_?
>> \/`!
>> |#*$^%=~{}+'-]+|\[([\x00-\x0C\x0E-\x5A\x5E-\x7F]|\\[\x00-\x7F])*\])
>> (\.
>> ([a-zA-Z0-9&_?\/`!|#*$^%=~{}+'-]+|\[([\x00-\x0C\x0E-\x5A\x5E-\x7F]|
>> \\[
>> \x00-\x7F])*\]))*$/
>
> It is trivial to create a formally correct address that makes
> absolutely
> no sense, so what's the point of doing such a complicated and
> error-prone validation?
Job security? I mean, without pointer arithmetic and its associated
mysteries (negative array indices were a personal favourite), we need
something to keep us gainfully employed!
matthew smillie.