-3

Regex Pattern for phone series 97890x00yz where x,y,z should not have same values ?

2 Answers2

1

Something like this will work for you :

public static void main(String... strings) {
    // String s = "97890x00yz";
       String s = "9789010023"; // output true.
    System.out.println(s.matches("97890(\\d)00(?!\\1)(\\d)(?!\\1|\\2)\\d"));
    //String s = "9789010022"; same regex - output : false
}
TheLostMind
  • 35,966
  • 12
  • 68
  • 104
0
97890(\d)00(?!\1)(\d)(?!\2|\1)\d

You can try this.See demo.

vks
  • 67,027
  • 10
  • 91
  • 124