Skip to content
Advertisement

How to write regular expression to match free email accounts?

I’m trying to write a regular expression that checks if an email form field contains a free email address, with no luck.

Essentially I need to check if the email contains: hotmail, yahoo, gmail etc in the email field.

Advertisement

Answer

regex would be sth like:

[a-zA-Z0-9_.+]+@(gmail|yahoo|hotmail)(.[a-z]{2,3}){1,2}

you can add all the other domains you want… does it help you?

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement