Use https://regex101.com/ to validate the expressions.
- Simple numbers only (no decimal and no fractions)
^(\d+)$
- Decimal numbers
^(\d*)[.,](\d+)$
- Alphanumeric without spaces
^(\w*)$
- Email (simple — see advanced section for more)
^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$
- Email tokens
^([a-z0-9_\.\+-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$
- Valid email (RFC5322)
\b[\w.!#$%&’*+\/=?^`{|}~-]+@[\w-]+(?:\.[\w-]+)*\b
- Username (simple)
Minimum length of 3, maximum length of 16, composed by letters, numbers or dashes.
/^[a-z0-9_-]{3,16}$/
- Strong password
Minimum length of 6, at least 1 uppercase letter, at least 1 lowercase letter, at least 1 number, at least 1 special character
(?=^.{6,}$)((?=.*\w)(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[|!"$%&\/\(\)\?\^\'\\\+\-\*]))^.*
- SSN — Social Security Number (simple)
If you want to check the validity of an SSN.
^((?<area>[\d]{3})[-][\d]{2}[-][\d]{4})$
- URL or IPv4 address
^(((h..ps?|f.p):\/\/)?(?:([\w\-\.])+(\[?\.\]?)([\w]){2,4}|(?:(?:25[0–5]|2[0–4]\d|[01]?\d\d?)\[?\.\]?){3}(?:25[0–5]|2[0–4]\d|[01]?\d\d?)))*([\w\/+=%&_\.~?\-]*)$