I can't get working a preg_match()
in PHP to validate an e-mail address. I've tested the RegEx expression that I've found on Internet with the http://www.regexer.com tool and works fine with the same input I'm using on my PHP application.
RegEx expression:
^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$
Regexer: http://regexr.com?2sr2a
And I'm applying it like this in PHP:
$email = "local@test.com";
$pattern = "/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix";
if (false == preg_match($pattern, $email))
echo "false";
And of course, I get a false with this e-mail and others that I've tested. The expression I think is well formed because on regexer I can test and it works. What I'm applying incorrectly?
Thank you in advance!