Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 23, 2022 10:38 am GMT

Regex that starts with letter, contains 1 uppercase/lowercase letter, one number and no special characters & min 8 characters

You need to put the lookaheads after ^ and put [a-zA-Z] right after them and quantify the rest with {8,}:

^(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])[a-zA-Z][a-zA-Z0-9]{8,}$

Regex that starts with letter, contains 1 uppercase/lowercase letter, one number and special characters & min 8 characters

^(?=.*[0-9])(?=.*[!@#$%^&*])[0-9a-zA-Z!@#$%^&*0-9]{8,}$

See the regex demo.
https://regex101.com/r/fGk1AC/1

> Pattern details:

  1. ^ - start of a string
  2. (?=.*?[a-z]) - at least 1 lowercase ASCII letter
  3. (?=.*?[A-Z]) - at least 1 uppercase ASCII letter
  4. (?=.*?[0-9]) - at least 1 ASCII digit5.[a-zA-Z] - an ASCII letter
  5. [a-zA-Z0-9]{7,} - 7 or more ASCII letters or digits (\w also allows _)
  6. $ - end of string.

Original Link: https://dev.to/bikashgosai/regex-that-starts-with-letter-contains-1-uppercaselowercase-letter-one-number-and-no-special-characters-min-8-characters-3n

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To