I'm trying to create a regular expression which will work on an email. I need to match that an email is either from a certain domain or from a certain domain and subdomain. A domain must be matched precisely.
I have this:
@.*\.?somedomain\.com$
Yes, this will match:
fdsafd@a1.somedomain.com
fdsafd@somedomain.com
fdsafd@aabbddjjj.somedomain.com
which is what I need. However, it'll also a domain which contains somedomain.com
as a part in it, and this isn't what I want:
fdsafd@partsomedomain.com
I want the domain somedomain.com
to be matched precisely.
How to fix it?