Regex to enforce password pattern

(?=^.{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/

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.