From: Paul Smith Date: 2009-09-24T19:12:57+09:00 Subject: Re: email regex On Thu, Sep 24, 2009 at 11:02 AM, Paul Smith wrote: > [^.@\s,] > > This character class excludes "." "@" whitespace and "," from being in > the first part of the e-mail. > > Remove the dot and sijo.kg@yahoo.com will be allowed. > > [^@\s,] > > /^([^@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i > > However, sijo..kg@yahoo.com will also be allowed.  It's up to you here > - do you want to make the regex perfect or will this be good enough. > > I think what you want is a optional repeating sequence of characters > followed by exactly 1 "." followed by a final sequence of characters > before the @ > > Something like this > > /^((?:[^@\s,]+.)*[^@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i Hmm, i forgot to escape a dot in there... /^((?:[^@\s,]+\.)*[^@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i > Maybe? > > Though you probably need to read here: > http://www.regular-expressions.info/email.html > http://blog.krugle.com/?p=208 > > > On Thu, Sep 24, 2009 at 10:48 AM, Sijo Kg wrote: >> Hi >> >>    I have a regular expression >> /^([^.@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i >> >> This exactly fits my need except for one. >> >>     But I have to pass this also   sijo.kg@yahoo.com      But Cannot. >> Please help me to add this also to the above >> >> Some example which are valid for above >> sijo@yahoo.com >> sijo@yahoo.co.uk >> >> Some example which are not valid for above >> .sijo@yahoo.com >> sijo..kg@yahoo.com >> sijo@@yahoo.com >> >> >> Thanks in advance >> Sijo >> -- >> Posted via http://www.ruby-forum.com/. >> >> > > > > -- > Paul Smith > http://www.nomadicfun.co.uk > > paul@pollyandpaul.co.uk > > -- Paul Smith http://www.nomadicfun.co.uk paul@pollyandpaul.co.uk