Matcher匹配器查找字符串指定内容
public static void main(String[] args) { String s = "我的手机号码是18988888888,曾经用过18987654321,还用过18812345678"; String regex = "1[3578]\\d{9}"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(s); while (m.find()) { System.out.println(m.group()); } }
代码成就万世基积沙镇海,梦想永在凌云意意气风发。