Reputation: 6540
I have to create a regular expression for email id like this
[email protected] and [email protected]
I need to allow only yahoo and gmail as the domain not any other domain. I have used this expression \w+([-+.]\w+)*@yahoo.com . It is working fine for yahoo. but I want to include gmail also. How can I modify it to except gmail also?
I am using ASP.NET 2.0
Upvotes: 1
Views: 9560
Reputation: 90062
Replace:
yahoo\.com
with:
(yahoo\.com|gmail\.com)
or:
((yahoo|gmail)\.com)
Upvotes: 6
Reputation: 27627
To put an alternative in you just need to do (yahoo\.com|gmail\.com)
and that should match either one.
Upvotes: 2
Reputation: 47213
Update: a ready made email validator can be found here; since it's from MSDN, it should be correct
Upvotes: 0