I’m trying to validate emails for a sign up forum with JavaScript using regular expression, I’m trying to understand how they work using a website called RegExr that checks the output of your regular expression
Regular expression to validate email :
/^(([a-z][A-Z]-_\d])+@([a-z][A-Z])+\.([a-z][A-Z])+)$/
As you can see here it doesn’t work. Can someone help ?
>Solution :
- you had
]at a place where it doesn’t belong here:\d]. - for all letter it is
[a-zA-Z]not[a-z][A-Z]. - for the numbers in this case it is better to use
[0-9]
Wat it should be:
^(([a-zA-Z0-9])+@([a-zA-Z])+\.([a-zA-Z])+)$
Note: an email address like this wont vallidate: jklm.qsdf@gmmail.com