As far as I know, it is not feasible to detect sequence numbers with regex
.
You can easily detect repeated characters, such as 000 or aaa, but a 123, 987 or abc sequence.
The regex
by itself, does not assign value to the characters. It does not identify that 2
is greater than 1
or that b
is followed by a
in the alphabet.
To do this you would have to write every possible sequence for it to give match on any of them. As an example the pattern " 123|12|23|321|32|21
" to identify a simple sequence between three numbers.
For repeated letters or numbers you could use a pattern that looks for repeated occurrences like " (\d|\w)+
".
In this case, the pattern gets a letter or number and then checks to see if it repeats one or more times.
See working at regex101 .