简体   繁体   中英

Regular Expression for atleast one character and one number with no repeat more than two

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

  • advan123 -valid
  • 1231123123ab -valid
  • advadvvadv12 -valid

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM