String.matches不包含从字符串中搜索的功能public class testReg {??? ??? public static void main(Strin
String.matches不包含从字符串中搜索的功能
public class testReg {
??? ??? public static void main(String[] args) {
??? ??? /* String.matches不包含从字符串中搜索的功能??? */
??? ??? ?//Matcher.find
??? ??? ?String check = "(1[358]\\d{9})";
??? ??? ?Pattern regex = Pattern.compile(check);
??? ??? ?Matcher matcher = regex.matcher("10-20 02:04:43??的姓名:陈女士,他(她)留下了电话:13731977879,请求您现在给他(她)拨电话。");
??? ??? ?boolean isMatched = matcher.find();
??? ??? ?System.out.println("Matcher.find:"+isMatched);
??? ??? ?
??? ??? ?/*用String.matches*/
??? ??? ?String input = "";
??? ??? ?System.out.println("String.matches:"+input.matches("(1[358]\\d{9})"));
??? ??? ?
??? ??? }
??? ??? }
