We want to check if number has repeat sequence for example - 111111
, 222222
etc. Below is the code :
String input = "222222";
public static String REGEX_REPEAT = "([\\d])\1{2}";
Pattern pattern = Pattern.compile(REGEX_REPEAT);
Matcher matcher = pattern.matcher(input.trim());
return matcher.matches();
But it always return false. I tried below regular expression also "([\\d])\\1{2}
"
Any Help appreciated.
Thanks