public static boolean matchPattern(String source, String pattern)
{
RE patt = getPatternObj(pattern);
if (patt.match(source)) {
return true;
}
else {
return false;
}
}
/**
* 获取匹配模式对象
*/
public static RE getPatternObj(String pattern)
{
RE patt = null;
try {
patt = new RE(pattern);
patt.setMatchFlags(RE.MATCH_SINGLELINE | RE.MATCH_CASEINDEPENDENT);
}
catch (Exception e) {
e.printStackTrace();
}
return patt;
}
阅读(1559) | 评论(0) | 转发(0) |