How to use
- Search for a format or filter by category.
- Click Copy to take the pattern; escape backslashes when you put it in a string.
- Type into the box under a card to see instantly whether it matches.
Options explained
- Syntax
- Written for JavaScript and compatible with most languages such as Java, Python, Go and PHP; inside string literals, double the backslashes.
- Whole-string matching
- Validation patterns are anchored with ^ and $ so the entire input must match. To search in longer text, drop the anchors and add the g flag.
- Format vs validity
- A pattern checks format only. Whether an ID or card number is real needs a checksum or an official check.
How a pattern is built: the IPv4 example
The IPv4 pattern shows the usual structure of a validation regex. One octet is written as four alternatives, tried in order, so each accepts only 0–255:
25[0-5] 250–255
2[0-4]\d 200–249
1\d\d 100–199
[1-9]?\d 0–99, with no leading zero
The whole pattern is (octet\.){3}octet, anchored with ^ and $. That is why 192.168.1.1 matches while 256.1.1.1, 01.2.3.4 and 1.2.3 do not.
Format is not validity
A pattern checks shape only. The date pattern accepts 2026-02-30 because it allows day 30 in every month, and rejects 2026-13-01 because month 13 does not exist. For real dates, parse the value with your language’s date library after the regex check.
Frequently asked questions
Why isn’t the email regex fully RFC-compliant?
A fully RFC 5322-compliant regex is huge and rejects few real mistakes. Use a lenient check and confirm the address with a verification email.
How do I debug a more complex regex?
Use the regex tester, which highlights every match and group and can test replacements.
Do these patterns support Unicode?
Most target ASCII input. Add the u flag and Unicode property escapes such as \p{L} if you need to accept letters from any script.
Privacy
This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.