I'm currently using this regex in my php script to validate email addresses:
preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);
Problem is, this specific regex is not reliable and often finds some false positives.
I was looking at regexlib.com to find a better one, but none of the ones I get from that site seem to find matches.
for example:
preg_match_all("^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$", $string, $matches);
finds nothing, even though it should work according to regexlib. I've tried the top 10 regex terms on regexlib for email validation and none of them work. Am I doing something wrong?
Link to regexlib email category: http://regexlib.com/DisplayPatterns.aspx?cattabindex=0&categoryId=1
Thanks,