regular expression to allow only these two type
i.e., something@ gmail.com
or [email protected]
only gmail or nishant .com should be allowed
what will b regex for this.
regex for gmail or nishant.com
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 9, 2013, 11:24 PM EDT
Try like this
use this pattern "^[a-zA-Z0-9._]+(@gmail\.com|@nishant\.com)$"
It allows like this string,
[email protected]
[email protected]..
Puneet GuptaRank #2,006 · 724 reputationPosted Oct 10, 2013, 12:32 AM EDT
if (reg.test(val))
alert("success");
else
alert("fail");
Thanks,
Puneet Gupta
nishant ranjanRank #4,961 · 317 reputationPosted Oct 10, 2013, 1:01 AM EDT