Allow special characters in e-mail Regex

Viewed 27

What is a proper Regex code to allow special characters like . _ - in email field

I have this Regex right now /^[a-zA-Z0-9]+@[a-zA-Z0-9]+\.[A-Za-z]+$/,

The above Regex only allow e-mails such as joedow@gmail.com

joe.dow@gmail.com does not work

How can I fix this ?

1 Answers

Just add those characters to the Regex:

^[a-zA-Z0-9\._-]+@[a-zA-Z0-9]+\.[A-Za-z]+$

https://regex101.com/r/xKkKIQ/1

This will make the regex consider ., _ and -. If you want any other characters, add them in the same way.

Related