I am looking for a regex that will prevent the insertion of a string, with arbitrary size, that contains only one character repeatedly.
For example these strings are invalid
aaaaaaaaaa
222
bbbbbbbb
@@@@@@@@@@@@@@@@
but these are valid
aaaaaaa2
@@@@@@@@@@@@f
b2222
I want it for an HTML5 text input:
<input type="text" class="form-control" placeholder="name" pattern="...">
答案 0 :(得分:3)
You can try the following:
^(?!^(.)\1+$).*$
It'd help if you also provide information about which tool you'll be using.