AnApprentice AnApprentice - 2 months ago 8
Javascript Question

JavaScript RegEx to determine the email's domain (yahoo.com for example)

With JavaScript I want to take a input
1st validate that the email is valid (I solved for this)
2nd, validate that the email address came from yahoo.com

Anyone know of a Regex that will deliver the domain?

thxs

Answer
/@yahoo.com\s*$/.test(mystring)

is true if the string ends in @yahoo.com (plus optional whitespace).