Regex to enforce password pattern

January 28, 2010

(?=^.{6,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[a-zA-Z]).*$

This regex will validate if:

  • password has at least 6 chars
  • contains at least 1 numeric digit
  • contains at least 1 character (uppercase OR lowercase

Nice piece of regex found on http://www.arjones.net/


Follow

Get every new post delivered to your Inbox.