从一堆手机号码中,找出xyz可不连续且重复3次的手机号码
package test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static Pattern pattern=Pattern.compile("(\\d{3})(.*\\1){2}");
public static void main(String[] args) {
String s1="13620446688";
Matcher m1=pattern.matcher(s1);
System.out.println(m1.find());
String s2="13613613600";
Matcher m2=pattern.matcher(s2);
System.out.println(m2.find());
String s3="13601360136";
Matcher m3=pattern.matcher(s3);
System.out.println(m3.find());
}
}
\1表示重复第一个括号里的内容