From: Paul Pladijs Date: 2001-03-25T09:47:49+09:00 Subject: [ruby-talk:13182] Re: email address regexp (fwd) (I'm sorry if this gets posted twice but the first something went wrong while posting this) On 23 Mar 2001, Randal L. Schwartz wrote: > The following message is a courtesy copy of an article > that has been posted to comp.lang.ruby as well. > > >>>>> "Paul" == Paul Pladijs writes: > > Paul> /\w+(\.\w+)*@\w+(\.\w+)*/ > > Paul> Referring to ruby-talk 12633, this is probably more correct. I think > Paul> it matches with the specification I found at http://www.rfc822.com > Paul> but I could be wrong. > > You're wrong. :) > > First hint is that *every* character except whitespace can be to the left > of the @ sign. One of my friends has the email address of *@qz.to > Yes. That's his address. Star at q z dot t o. > Okay, let's update the regexp: /\S+@\w+(\.\w+)*/ This one matches email addresses like: *@qz.to Unfortunely it also matches something like: abc@def@rug.ac.be Maybe we could solve this with a second regexp, one that should not match with the email address: /\S*(@\S*@)+\S*/ But it's easier to count the number of '@' symbols in the candidate-email-address string. So if anyone has or knows an email address that doesn't match the first regexp, or that matches the second regexp, please let me know. After an (in)finite amount of time we will have the right regular expression(s). Remark: it's possible to merge those two regexp into a single regexp. One day I'll do that :-) Regards, Paul.