Edited after comments
I think you mean that you do not want the same number to be repeated 9 times. To do this, you need to write down one digit and turn to it and see if it repeats another 8 times.
@Pattern(regexp="^(?!(\\d)\\1{8})")
If you just use \\d{9} , this will mean repeating any digits.
Also note that you do not need to .* . Regex will decide where to start the match on its own.
sawa source share