First of all, I know that using regex for email is not recommended but I gotta test this out.
I have this regex:
[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}
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("[email protected]");
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,
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…