email regex

S

Sijo Kg

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 (e-mail address removed) But Cannot.
Please help me to add this also to the above

Some example which are valid for above
(e-mail address removed)
(e-mail address removed)

Some example which are not valid for above
(e-mail address removed)
(e-mail address removed)
sijo@@yahoo.com


Thanks in advance
Sijo
 
P

Paul Smith

[^.@\s,]

This character class excludes "." "@" whitespace and "," from being in
the first part of the e-mail.

Remove the dot and (e-mail address removed) will be allowed.

[^@\s,]

/^([^@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i

However, (e-mail address removed) 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=3D208


Hi

=A0 =A0I have a regular expression
/^([^.@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i

This exactly fits my need except for one.

=A0 =A0 But I have to pass this also =A0 (e-mail address removed) =A0 =A0 =A0But= Cannot.
Please help me to add this also to the above

Some example which are valid for above
(e-mail address removed)
(e-mail address removed)

Some example which are not valid for above
(e-mail address removed)
(e-mail address removed)
sijo@@yahoo.com


Thanks in advance
Sijo



--=20
Paul Smith
http://www.nomadicfun.co.uk

(e-mail address removed)
 
P

Paul Smith

[^.@\s,]

This character class excludes "." "@" whitespace and "," from being in
the first part of the e-mail.

Remove the dot and (e-mail address removed) will be allowed.

[^@\s,]

/^([^@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i

However, (e-mail address removed) will also be allowed. =A0It'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=3D208


Hi

=A0 =A0I have a regular expression
/^([^.@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i

This exactly fits my need except for one.

=A0 =A0 But I have to pass this also =A0 (e-mail address removed) =A0 =A0 =A0Bu= t Cannot.
Please help me to add this also to the above

Some example which are valid for above
(e-mail address removed)
(e-mail address removed)

Some example which are not valid for above
(e-mail address removed)
(e-mail address removed)
sijo@@yahoo.com


Thanks in advance
Sijo



--
Paul Smith
http://www.nomadicfun.co.uk

(e-mail address removed)



--=20
Paul Smith
http://www.nomadicfun.co.uk

(e-mail address removed)
 
S

Sijo Kg

Hi Paul Smith

Thanks for the reply But if I use
/^((?:[^@\s,]+.)*[^@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i

It fails
(e-mail address removed)
(e-mail address removed) and
sijo@[email protected]



Sijo
 
S

Sijo Kg

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

(e-mail address removed) and
(e-mail address removed)


Sijo
 
P

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)

Hi Paul Smith
=A0Thanks again
Hmm, i forgot to escape a dot in there...

=A0/^((?:[^@\s,]+\.)*[^@\s,]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i

=A0 =A0 When tried this I get 2 failures

(e-mail address removed) =A0 =A0and
(e-mail address removed)


Sijo



--=20
Paul Smith
http://www.nomadicfun.co.uk

(e-mail address removed)
 
S

Sijo Kg

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top