Link to home
Start Free TrialLog in
Avatar of PagodNaUtak
PagodNaUtakFlag for Philippines

asked on

Regular expression email validation

Hi,

I have the below javascript code that validates email address, unfortunately this regular expression does not accept the email address o'neil@yahoo.com. How do I revise the code below so that it will accept email address with apostrophe?

Your input is greatly appreciated.


var objRegEx = /(^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;

Open in new window

Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Try this:

var objRegEx = /(^[a-zA-Z0-9._-']+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$)|(^[a-z]([a-z_\.']*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.']*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
Avatar of PagodNaUtak

ASKER

I receive syntax error in regular expression.
SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial