First of all, I know that using regex for email is not recommended but I gotta test this out.
I have this regex:
\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b
In Java, I did this:
Pattern p = Pattern.compile("\\b[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b");
Matcher m = p.matcher("foobar@gmail.com");
if (m.find())
System.out.println("Correct!");
However, the regex fails regardless of whether the email is wel-formed or not. A "find and replace" inside Eclipse works fine with the same regex.
Any idea?
Thanks,