Sijo_Kg
(Sijo Kg)
24 September 2009 09:48
1
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/ .
[^.@\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
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 <sijo@maxxion.com> 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
Sijo Kg:
I have a regular expression
/^([^.@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
This exactly fits my need except for one.
If your needs are checking email addresses’
validity, you really want to use something like¹
/^([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])*\]))*$/
…as
" spaces! @s ! \"escaped quotes!\" "@yahoo.com
is a perfectly valid email address.
(Note that
" spaces! @s ! \"escaped quotes!\" "@łódź.pl
is also a perfectly valid email address which the above doesn’t match.)
You might want to check
¹ http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/173923?173909-178505
for the discussion on this.
— Shot
···
--
anyone who finds the MS Office ribbon intuitive is not a member
of the human species as I understand it [William Morgan]
[^.@\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
···
On Thu, Sep 24, 2009 at 11:02 AM, Paul Smith <paul@pollyandpaul.co.uk> wrote:
Maybe?
Though you probably need to read here:
How to Find or Validate an Email Address
http://blog.krugle.com/?p=208
On Thu, Sep 24, 2009 at 10:48 AM, Sijo Kg <sijo@maxxion.com> 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
Sijo_Kg
(Sijo Kg)
24 September 2009 10:16
5
Hi Paul Smith
Thanks for the reply But if I use
/^((?:[^@\s,]+.)*[^@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
It fails
.sijo.kg@yahoo.com
sijo..kg@yahoo.com and
sijo@kg@yahoo.com
Sijo
···
--
Posted via http://www.ruby-forum.com/ .
Sijo_Kg
(Sijo Kg)
24 September 2009 10:22
6
Hi Paul Smith
Thanks again
Hmm, i forgot to escape a dot in there...
/^((?:[^@\s,]+\.)*[^@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
When tried this I get 2 failures
.sijo.kg@yahoo.com and
sijo..kg@yahoo.com
Sijo
···
--
Posted via http://www.ruby-forum.com/\ .
Did you read the pages I linked to?
/^((?:[^.@\s,]+\.)*[^.@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
(I forgot to put the . back in the excluded character classes at the start)
···
On Thu, Sep 24, 2009 at 11:22 AM, Sijo Kg <sijo@maxxion.com> wrote:
Hi Paul Smith
Thanks again
Hmm, i forgot to escape a dot in there...
/^((?:[^@\s,]+\.)*[^@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
When tried this I get 2 failures
.sijo.kg@yahoo.com and
sijo..kg@yahoo.com
Sijo
--
Posted via http://www.ruby-forum.com/\ .
--
Paul Smith
http://www.nomadicfun.co.uk
paul@pollyandpaul.co.uk
Sijo_Kg
(Sijo Kg)
24 September 2009 10:44
8
Hi Paul Smith
Did you read the pages I linked to?
/^((?:[^.@\s,]+\.)*[^.@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
(I forgot to put the . back in the excluded character classes at the
start)
Lots of thanks.Now it works perfectly.Since it was a sudden fix I did
not .But now I start reading that pages to get a very good understanding
of regex
Thanks once again
Sijo
···
--
Posted via http://www.ruby-forum.com/\ .