正则表达式概述与JAVA中正则表达式的应用 (二)

2014-11-24 10:33:29 · 作者: · 浏览: 2

Matcher matcher = pattern.matcher(input) //进行匹配
if (matcher.matches()) check = true;
return check;

boolean check = false;
String regex = "\w+@\w+\.(com)|(cn)";
String input = "19100390888";
Pattern pattern = Pattern.compile(regex) //编译正则表达式
Matcher matcher = pattern.matcher(input) //进行匹配
if (matcher.matches()) check = true;
return check;