Background
I'm working on a Javascript application where users have to use a specific email domain to sign up (Either @a.com or @b.com. Anything else gets rejected).
I've created a regex string that makes sure the user doesn't do @a.com with nothing in front of it and limits users to only @a.com and @b.com. The last step is to make sure the user doesn't add extra characters to the end of @a.com by doing something like @a.com.gmail.com
This is the regex I currently have:
\b[a-zA-Z0-9\.]*@(a.com|b.com)
Question
What can I use at the end to prevent anything from being added after a.com or b.com? I'm very novice at regex and have no idea where to start.
$to the regex's end.$means your match should be at the strings' end\b[a-zA-Z0-9\.]*@[ab]\.com$mflag on it. Works perfectly. If you put it in an answer, I'll accept it. Thanks!!(m)ultilineflag threats each line as a separate string