Skip to content

Instantly share code, notes, and snippets.

@hanetooth
Created March 23, 2018 02:38
Show Gist options
  • Save hanetooth/72c321675b8baca429b7534898fcc8d3 to your computer and use it in GitHub Desktop.
Save hanetooth/72c321675b8baca429b7534898fcc8d3 to your computer and use it in GitHub Desktop.
Regex pattern for strong password php
^\S*(?=\S{8,})(?=\S*[a-z])(?=\S*[A-Z])(?=\S*[\d])\S*$
From the fine folks over at Zorched.
^: anchored to beginning of string
\S*: any set of characters
(?=\S{8,}): of at least length 8
(?=\S*[a-z]): containing at least one lowercase letter
(?=\S*[A-Z]): and at least one uppercase letter
(?=\S*[\d]): and at least one number
$: anchored to the end of the string
To include special characters, just add (?=\S*[\W]), which is non-word characters.
Source: https://stackoverflow.com/a/8141210/6887746
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment