Regex Pattern Library
Start from a tested validation pattern, run the included positive and negative test vectors in your browser, read the limitations, then adapt the regex to your application instead of copying an unexplained expression from a snippet.
UUID v4 regex
Test a UUID v4 regex against valid and invalid identifiers. Copy the JavaScript-compatible pattern, inspect version and variant constraints, and verify examples.
^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$IPv4 address regex
Test a strict IPv4 regex for four decimal octets from 0 to 255. Copy the pattern, run valid and invalid addresses, and understand common IPv4 regex mistakes.
^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$IPv6 address regex
Test an IPv6 regex that supports full and compressed hexadecimal address forms. Review examples, limitations, and when an IP parser is safer than regex.
^(?:(?:[0-9a-f]{1,4}:){7}[0-9a-f]{1,4}|(?:[0-9a-f]{1,4}:){1,7}:|(?:[0-9a-f]{1,4}:){1,6}:[0-9a-f]{1,4}|(?:[0-9a-f]{1,4}:){1,5}(?::[0-9a-f]{1,4}){1,2}|(?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,3}|(?:[0-9a-f]{1,4}:){1,3}(?::[0-9a-f]{1,4}){1,4}|(?:[0-9a-f]{1,4}:){1,2}(?::[0-9a-f]{1,4}){1,5}|[0-9a-f]{1,4}:(?:(?::[0-9a-f]{1,4}){1,6})|:(?:(?::[0-9a-f]{1,4}){1,7}|:))$ISO date (YYYY-MM-DD) regex
Test a YYYY-MM-DD regex with month and day ranges. Copy the pattern, verify ISO-style date strings, and learn why calendar-valid dates still need date parsing.
^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$Semantic Version regex
Test a SemVer regex for MAJOR.MINOR.PATCH versions with optional prerelease and build metadata. Copy the pattern and verify valid and invalid semantic versions.
^(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-]+)*))?$URL slug regex
Test a lowercase URL slug regex for letters, digits, and single hyphens. Copy the pattern and verify valid and invalid SEO-friendly slug examples.
^[a-z0-9]+(?:-[a-z0-9]+)*$Hex color regex
Test a CSS hex color regex for 3, 4, 6, or 8 hexadecimal digits after #. Copy the pattern and verify RGB and alpha hex color examples.
^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$Validation patterns are starting points
A pattern that is correct for one product can be wrong for another. Slugs may allow Unicode in one CMS and ASCII only in another. IP input may allow normalized forms in one system and require a parser in another. Use each reference to understand what the regex accepts before adopting it.
Need a custom pattern?
Use the main Regex Tester when the input format is application-specific, you need capture groups, or you are searching within larger text rather than validating the whole value.
Open Regex Tester →