1

Would some one please tell me the following Regex?

At least eight or more characters. At least one lower-case letter. At least one upper-case letter. At least one number.

Thanks in advance.

Variation on Complex Password Regular Expression

Community
  • 1
  • 1
Fred Chateau
  • 869
  • 1
  • 6
  • 16
  • 5
    Did you try something yourself? Mind posting the code? – Stefan van den Akker Jun 03 '14 at 14:21
  • You don't need to cram every single bit of everything into a single regex. I strongly suggest you use multiple regexes for your password validation. Validate against one that checks that there's a digit, another that checks for uppercase letters, another for lowercase letters, etc. It will be far more readable, and much easier to modify later if you change your password requirements. – Andy Lester Jun 03 '14 at 15:15
  • possible duplicate of [Complex password Regular expression](http://stackoverflow.com/questions/3466850/complex-password-regular-expression) – Andy Lester Jun 03 '14 at 15:16
  • Yes, it would be duplicate of Complex password Regular expression, as that is what I was attempting to do. Andy, it never occurred to me to divide it up, as I was thinking of it as one word. Also, guys, it certainly doesn't seem unclear to everyone else here, not to mention the question was answered. – Fred Chateau Jun 03 '14 at 15:58
  • @Neftas IMHO Regex questions are usually an exception to 'what have you tried' rule cause the answer is usually very short and doesn't require writing code. – Nir Alfasi Jun 03 '14 at 16:18

1 Answers1

1

You can use this lookahead based regex:

^(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9]).{8,}$
anubhava
  • 761,203
  • 64
  • 569
  • 643