I'm trying to use the following regular expression to validate emails in a MySQL database:
^[^@]+@[^@]+\.[^@]{2,}$
in a condition like this:
...and email REGEXP '^[^@]+@[^@]+\.[^@]{2,}$'
For the most part, the expression is working. But it's allowing single-character top level domains. For example, both the following emails pass validation:
something@hotmail.com and something@hotmail.c
The second case is clearly a typo. The {2,} of the regex should allow any string of characters other than the @ symbol, of length 2 or more, after the dot.
I've run the regex itself through multiple testers running different protocols, (Perl, TCL, etc.) and it works as expected every time, rejecting the single-character TLD version of the email address. It's only when I use this regex in a MySQL context that it fails.
I've checked, and there are no additional characters after the ".c" in the erroneous email address. Is there something inherent to MySQL or this version that could be preventing this from working?
Running MySQL version 5.5.61-cll