示例1:
public static void main(String[] args) {
String s="99-3933";
boolean b=Pattern.matches("([\\d])\\1[-]([3])\\1\\2{2}", s);
System.out.println(b);
}
反向引用,匹配重复的数字
([\d])====>\1
([3])====>\2
示例2:
public class test {
public static void main(String[] args) {
String s="99-393399-3933";
boolean b=Pattern.matches("(([\\d])\\2[-]([3])\\2\\3{2})\\1", s);
System.out.println(b);
}
}