Hey I have the follow email validation expression
^[\w-.]+@([\w-]+.)+[\w-]{2,4}$
What I am looking for is for email addresses to be allowed which have a "+" before the @ part of the email cheers
Hey I have the follow email validation expression
^[\w-.]+@([\w-]+.)+[\w-]{2,4}$
What I am looking for is for email addresses to be allowed which have a "+" before the @ part of the email cheers
Just change it to ^[\w-.]+(?:\+[\w]*)?@([\w-]+.)+[\w-]{2,4}$
This allows for + before @ and some characters which is optional. So [email protected] [email protected] are both valid.
Updated.
Or use a full RFC 822 regex
^((?>[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+\x20*|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*"\x20*)*(?<angle><))?((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+)+|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*")@(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}|\[(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)\])(?(angle)>)$
And the RegexLib is great place for finding regex for most requirements, you are rarely the first to want to do something.