Reputation: 1522
I'm currently using this very relaxed REGEX to validate email addresses:
(/(.+)@(.+)\.(.+){2,}/.test(emailAddress)
I believe that it only allows min1_allowsDots@min1_allowsDots.min2 - is this correct?
How should I modify it to match only a particular domain - anything@ onlythisdomain.com?
TIA!
iSofia
Upvotes: 0
Views: 967
Reputation: 31
Maybe this could help you:
^[a-zA-Z0-9_.+-]+@(?:(?:[a-zA-Z0-9-]+\.)?[a-zA-Z]+\.)?
(company_domain1|company_domain2)\.ca$/g
It is a regex where you can validate the email including a specific domain such as
[email protected]
or [email protected]
and it will match only if the email is ending with @doctorgroup.ca
or @doctors.ca
.
Upvotes: 0
Reputation: 7771
This simple RegEx basically says:
At least one character, then an "@", then literally "gmail.com".
If you change the domain to something else, it will not match.
var email = '[email protected]';
var re = /.+\@gmail\.com/;
alert(email.match(re));
Upvotes: 0
Reputation: 67968
(.+)@onlythisdomain\.(.+){2,}
This should do it.If .com
is also fixed use
(.+)@onlythisdomain\.com
Upvotes: 2