View Full Version : How do I include a ‘dot’ and a ‘hyphen’ in the name section of an email address with

Ade B
07-21-2010, 10:15 AM
This is the regular expression I currently have
/^(\w+|\w+.\w+)@(\w+|\w+\-\w+)\.(\w{2,3}|\w{2,3}\.\w{2,3})$/; the script dates from about 2006. The script is ok for emails that just contain a ‘dot’ before the @, as in:

What needs to be changed in the above script to allow both these types of email?
joe.bloggs@home.com and

Any help greatly appreciated.

07-21-2010, 11:53 AM
use a character class

ok, that allows more than exactly one . or -, though

Ade B
07-21-2010, 03:45 PM
Thank you Dormilich, your answer was perfect. I have tested the form and it
now works as I wanted - Much appreciated