PCRE: /\A[A-Z0-9_\.%\+\-]+@(?:[A-Z0-9\-]+\.)+(?:[a-z]{2,4}|museum|travel)\z/i
POSIX: /^[A-Z0-9_\.%\+\-]+@(?:[A-Z0-9\-]+\.)+(?:[A-Z]{2,4}|museum|travel)$/i
This regular expression is correct in every way for my needs, except that it allows you to send emails such as jim@f.com. He says this is a match. If I’m not mistaken, does {2,4} after [AZ] not mean that it should be from 2 to 4 characters? Maybe this is a problem with a quarrel, a museum and travel? I have confirmed that this is allowed in my application, and several regular expression testers. Also, I'm fuzzy about what PCRE and POSIX really did. I am afraid that they might just be PCRE, and I laugh. AFAIK, JavaScript is POSIX, and Ruby is PCRE. So if I didn’t get it right, please forgive me , it was a long, long night of learning regular expressions, in and out, and I'm trying to look badass. :)
source
share