Tested regular expressions you can open in the tester, read the explanation of and adapt. Each pattern comes with sample text and unit tests. Save your own pattern with Save & share and tick “publish” to add it here.
6 patterns
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$
At least 8 characters with a lowercase letter, an uppercase letter, a digit and a special character – each rule is one lookahead, so they are easy to change.
^[\w.+-]+@[A-Za-z\d-]+(\.[A-Za-z\d-]+)*\.[A-Za-z]{2,}$
Accepts the e-mail addresses people really use (letters, digits, dots, plus tags, hyphens, multi-level domains) and rejects common typos. Anchored for validating a whole input value.
(?:\+1[ .-]?)?\(?([2-9]\d{2})\)?[ .-]?(\d{3})[ .-]?(\d{4})\b
(415) 555-2671, 415-555-2671, 415.555.2671 and +1 415 555 2671.
^\+[1-9]\d{6,14}$
A plus sign followed by up to 15 digits, the format used by most SMS and telephony APIs.
^[A-Za-z][\w.]{1,14}[A-Za-z\d_]$
3 to 16 characters: letters, digits, underscores and dots; must start with a letter and cannot end with a dot.
\b(?:4\d{3}|5[1-5]\d{2}|2[2-7]\d{2})(?:[ -]?\d{4}){3}\b|\b3[47]\d{2}[ -]?\d{6}[ -]?\d{5}\b
Visa, Mastercard and American Express number formats with optional spaces or dashes. Checks the shape only – use the Luhn checksum in code.