I want to check username validation before signup, but it is a little bit complex, I tried too many variation but I could not.
For example;
VALID:
username
username1
username23
username456
7username
89username
123username
user_name
user_name1
1user_name2
123user_name
1u2s3er
4u5s6er
INVALID:
_username <-- start with underscore
username_ <-- end with underscore
_username_ <-- contains underscore more than 1, start and end with underscore
user__name <-- contains underscore more than 1
user_na_me <-- contains underscore more than 1
username1000 <-- contains number more than 3
user01name23 <-- contains number more than 3
1u2s3e4r <-- contains number more than 3
This regex rule is good for my first three conditions but I need add limit for numbers and underscores.
^(?=.{6,20}$)(?![_])[a-zA-Z0-9çÇ_]+(?<![_])$
Thanks.
I SOLVED, THANKS.
THE SOLUTION;
^(?!(.*[_].*){2,}$)(?!(.*[0-9].*){4,}$)(?=.{6,20}$)(?![_])[a-zA-Z0-9çÇ_]+(?<![_])$