Reputation: 320
I am trying one of regular expression for condition like:
atleast 1 number, atleast 1 character, should be 3 to 16 digit long. No character and number should repeat more than 2 time.
I tried one regular expression here what i tried.
(^(?=.*\d)(?=.*[a-zA-Z]).{3,16}$)\1{2,}
but it did not do the trick.
example for valid and invalid post:
advan@123 -valid
advan@4 -valid
advvvan@123 -invalid
advan@11123 -invalid
Upvotes: 1
Views: 126
Reputation: 626747
You can try using this regex (edited to fail strings that have triple consecutive symbols):
^(?=.*[0-9])(?=.*[a-zA-Z])(?!.*(.)\1\1.*).{3,16}$
See example here.
Upvotes: 2