这种方法是使用Pattern类和Matcher类:
Pattern p = Pattern.compile("正则表达式");
Matcher matcher = p.matcher("字符串");
boolean result = matcher.matches();
或者:
boolean result = Pattern.matches("正则表达式","字符串");
这种方法是使用Pattern类和Matcher类:
Pattern p = Pattern.compile("正则表达式");
Matcher matcher = p.matcher("字符串");
boolean result = matcher.matches();
boolean result = Pattern.matches("正则表达式","字符串");