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

Regex to match a email to contains at least one character

I need a regex to match an email which:

  • must contain at least one alphabet
  • can contain digits
  • can contain _ and ..
  • must be an email format (i.e., contains @something.something)

I have found this

^((?=.*[a-zA-Z])\w+([\.-]?\w+)*)@\w+([\.-]?\w+)*(\.\w{2,3})+$

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

but it is accepting 12345@gmail.com, which is invalid according to my specs

>Solution :

As per your specs I’ve created the following Regex for you

^\w*[A-Za-z]+(?:([._]?\w+)*)\@[A-Za-z]\w*[-]?\w+\.[A-Za-z]{1,}?(\.?[A-Za-z]+)$

It should work for all your edge cases, and it also covers all the domain names including with - like former-player and also .co.uk and such

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