I want to prevent users to just use repeated one letter or any others characters in whole string of username or password fields for registering new user by PHP. I search in google and regex wiki and stackoverflow and regex101 but I couldn't find my answer.
minimum of length for username and password characters is 8.
Rules:
in username or password fields for registering new user 11111111,111111111111,22222222,222222222222,...,aaaaaaaa,aaaaaaaaaaaa,bbbbbbbb,...,zzzzzzzz,...@@@@@@@@,******** ,&&&&&&&&... should be invalid but 11111113,22222221,...,aaaaaaab,baaaaaaa,...,zzzczzzz,...@@@1@@@@,2******* ,&&&&&n&&... should be valid.
I found this patterns but doesnt work and has warning:
pattern1: ^(?!.*(.)\1).{*}$
pattern2: ^(.)\1{1,}$
warning is this:
Warning: preg_match(): No ending delimiter '^' found in C:...\test.php on line 70
please help me to resolve that.
this posts was not my answer and doesnt work:
match the same unknown character multiple times
Perl Regex prevent repeated characters for password policy
UPDATE:
Thanks panter.it works==>~^(.)\1{1,}$~
Thanks solarc. Your suggestion is good.