A regular expression (shortened as regex or regexp or rational expression) is a sequence of characters that specifies a search pattern in the text.
A good testing site is
https://infoheap.com/php-preg_match-online/
Examples of regex for password
PHP Version
/^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z])(?=\S*[\W]).{8,}$/
Must have special characters
(?=\S*[\W])
Must have a number
(?=.*\\d)
Must have uppercase and lowercase
(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z])
Some reference
https://stackoverflow.com/questions/8141125/regex-for-password-php
https://stackoverflow.com/questions/19605150/regex-for-password-must-contain-at-least-eight-characters-at-least-one-number-a