Examples
Emails
Matches valid email addresses.
^(?:[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$Another pattern to match valid email addresses.
^\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b$Yet another pattern to match valid email addresses.
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$URLs
Matches URLs with optional protocol and subdomains.
^(?:https?://)?(?:www\.)?[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:/\S*)?$Another pattern to match URLs.
^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$ Yet another pattern to match URLs.
^(https?|ftp):\/\/[a-zA-Z0-9]+\.[a-zA-Z0-9]+\.[a-zA-Z0-9]+\.[a-zA-Z0-9]+\/[^\s]*$Numbers (with and without decimals)
Matches numbers with optional sign and decimal points.
^-?\d+\.?\d*$Another pattern to match numbers.
^-?\d+(\.\d+)?$Yet another pattern to match numbers.
^-?[0-9]+(\.[0-9]+)?$Dates of all known formats
Matches dates in various formats.
^(?:(?:0?[1-9]|1[0-2])[-\/.](?:0?[1-9]|[12]\d|3[01])[-\/.]\d{4})|(?:(?:0?[1-9]|[12]\d|3[01])[-\/.](?:0?[1-9]|1[0-2])[-\/.]\d{4})|(?:(?:0?[1-9]|1[0-2])[-\/.]\d{1,2}[-\/.]\d{2,4})$Another pattern to match dates.
^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$Yet another pattern to match dates.
^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$Time in all known formats
Matches time in various formats.
^(?:0?[1-9]|1[0-2]):(?:[0-5]\d)(?::(?:[0-5]\d))?(?:\s?[APap][mM])?$Another pattern to match time.
^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$Yet another pattern to match time.
^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])(:[0-5][0-9])?$Phone Numbers
Matches US phone numbers with optional area code and formatting.
^(?:\+?1[-. ]?)?\(?[2-9][0-9]{2}\)?[-. ]?[2-9][0-9]{2}[-. ]?\d{4}$Another pattern to match phone numbers.
^(\+\d{1,2}\s?)?((\(\d{3}\))|\d{3})([\s.-]?)\d{3}([\s.-]?)\d{4}$Yet another pattern to match phone numbers.
^([+]?[0-9]{1,2}[.-\s]?)?(\([0-9]{3}\)|[0-9]{3})[.-\s]?[0-9]{3}[.-\s]?[0-9]{4}$Zip Codes
Matches US zip codes in various formats.
^\d{5}(?:-\d{4})?$Another pattern to match US zip codes.
^\d{5}-\d{4}(?:\d{2})?$Yet another pattern to match US zip codes.
^\d{5}(?:-\d{4})?$Password Strength validation
Matches passwords with at least 8 characters, containing at least one uppercase letter, one lowercase letter, one number, and one special character.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$Another pattern for password validation.
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$Yet another pattern for password validation.
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$File Extensions
Matches file extensions (e.g., .txt, .jpg, .pdf).
\.\w+$Another pattern to match file extensions.
\.(?:jpg|gif|png|pdf|)$IPv4 Addresses
Matches IPv4 addresses in dotted decimal notation.
^(?:\d{1,3}\.){3}\d{1,3}$Another pattern to match IPv4 addresses.
^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$Credit Card Numbers
Matches credit card numbers in various formats.
^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})$Another pattern to match credit card numbers.
^(?:\d[ -]*?){13,16}$City, State Abbreviations
Matches US city names followed by state abbreviations.
^[a-zA-Z\s]+,\s*[A-Z]{2}$Another pattern to match city names and state abbreviations.
^[a-zA-Z\s]+,\s*[A-Z]{2}$Social Security Numbers
Matches US social security numbers in various formats.
^(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}$Another pattern to match social security numbers.
^\d{3}-\d{2}-\d{4}$Dollar Amounts
Matches dollar amounts in various formats.
^\$?\d{1,3}(?:,?\d{3})*(?:\.\d{2})?$Another pattern to match dollar amounts.
^\$[0-9]+(\.[0-9]{2})?$Hexadecimal Values
Matches hexadecimal values.
^(?:0[xX])?[0-9a-fA-F]+$Another pattern to match hexadecimal values.
^#?([a-f0-9]{6}|[a-f0-9]{3})$MAC Addresses
Matches MAC addresses in various formats.
^(?:[0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$Another pattern to match MAC addresses.
^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$HTML Tags
Matches HTML tags.
<[^>]*>Another pattern to match HTML tags.
<[a-zA-Z][^>]*>Last updated
Was this helpful?