public static List<String> getPhone(String str){
if(str == null || "".equals(str)){
return null;
}
String regex2 = "1[3456789]\\d{9}";
Pattern p = Pattern.compile(regex2);
Matcher matcher = p.matcher(str);
List<String> list = new ArrayList<>();
while (matcher.find()){
list.add(matcher.group());
}
return list;
}
String regex2 = "1[3456789]\\d{9}";
匹配第一位是1,第二位是3456789中的任何一位,后面再跟9位数字的字符串。