Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Issue in validating regular expression

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])+)$/

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

As you can see here it doesn’t work. Can someone help ?

>Solution :

  1. you had ] at a place where it doesn’t belong here: \d].
  2. for all letter it is [a-zA-Z] not [a-z][A-Z].
  3. 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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading