devkult_
tools29converters34
home/regex

Regex Pattern Library

26 ready-made validation patterns — each explained token by token, with match examples and a live tester. Building your own instead? Use the regex tester.

Regex for Email Validation
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Regex for URL Validation
^https?:\/\/[\w.-]+(?:\.[\w-]+)+[^\s]*$
Regex for Phone Number Validation
^\+?[1-9]\d{7,14}$
Regex for UUID Validation
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
Regex for IPv4 Address Validation
^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$
Regex for IPv6 Address Validation
^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$
Regex for Dates in YYYY-MM-DD Format
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
Regex for 24-Hour Time (HH:MM)
^([01]\d|2[0-3]):[0-5]\d$
Regex for Password Validation
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$
Regex for Username Validation
^[a-zA-Z0-9_]{3,16}$
Regex for Hex Color Codes
^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
Regex for URL Slug Validation
^[a-z0-9]+(?:-[a-z0-9]+)*$
Regex for MAC Addresses
^(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}$
Regex for US ZIP Codes
^\d{5}(?:-\d{4})?$
Regex for UK Postcodes
^[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}$
Regex for Credit Card Numbers
^(?:\d[ -]?){12,18}\d$
Regex for Semantic Versions (SemVer)
^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
Regex for Domain Names
^(?=.{1,253}$)(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,63}$
Regex for HTML Tags
<\/?[a-zA-Z][a-zA-Z0-9-]*\b[^>]*>
Regex for ISO 8601 Date-Times
^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$
Regex for Numbers Only (Digits)
^\d+$
Regex for Decimal Numbers
^-?\d+(?:\.\d+)?$
Regex for Alphanumeric Strings
^[a-zA-Z0-9]+$
Regex to Trim Leading and Trailing Whitespace
^\s+|\s+$
Regex for Base64 Strings
^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$
Regex for JSON Web Tokens (JWT)
^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*$