-10
我有一些代码:???什么字符((:(:(?:意味着模式匹配
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
private boolean validateEmail(...)
Pattern p = Pattern.compile("^((?:(?:(?:[a-zA-Z0-9][\\.\\-\\+_]?)*)[a-zA-Z0-9])+)\\@((?:(?:(?:[a-zA-Z0-9][\\.\\-_]?){0,62})[a-zA-Z0-9])+)\\.([a-zA-Z0-9]{2,6})$");
Matcher m = p.matcher(fieldValue);
boolean matches = m.matches();
if (!matches) {
// show not valid msg...
}
return matches;
}
什么^((?:(?:(?:
和((?:(?:(?:
在这种模式意味着 的^
字符意味着什么?当你想组的表达否定(所有这些都不),但是其它字符?
[文档](http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html)告诉你它们是什么意思? –
这里有几个Java正则表达式教程让你开始:http://www.vogella.com/articles/JavaRegularExpressions/article.html http://docs.oracle.com/javase/1.4.2/docs/api /java/util/regex/Pattern.html – codeMan
他们是微笑 - 这就是正则表达式如何表达对你的同情。 –