It looks like you are making three separate regular expressions, presumably denying the result of the second and third. In this case, this should do the trick:
pinString.matches("^\\d{6}$") !pinString.matches("^.*?(?:0123|1234|2345|3456|4567|5678|6789).*$") !pinString.matches("^.*?(\\d)\\1{2}.*$")
With the matches() method, you really don't need anchors ( ^ and $ ), but they don't hurt, and they make your intentions more obvious. In addition, the first regular expression ensures that all six characters are numbers, so itβs safe to use . instead of \\d as a space placeholder in the other two.
source share