Regex Library
Regex is a pattern language, not a validator of the real world. An email regex cannot prove an inbox exists. This library keeps common, commented patterns (email-shaped strings, URLs, phones, IPv4) with test strings so you can see what they match before you paste them into production.
What the regex pattern library is for
Regular expressions for common tasks — validating an email, matching an IP address, extracting a URL — are easy to get subtly wrong, and a flawed pattern either rejects valid input or lets bad input through.
Starting from a tested pattern is faster and safer than writing one from scratch each time.
Common uses
- Finding a starting pattern for form validation
- Learning regex syntax from worked examples
- Extracting structured values from log lines
- Checking your own pattern against a known-good one
What the output means in the real world
Each pattern is a starting expression plus samples. Copy it into a unit test, then add your own failing cases before it reaches production. Over-tight regex on emails (rejecting plus-addressing) locks out Gmail users. Over-loose regex on redirects becomes an open redirect. Tune the library row; do not paste it as a final gate.
How this fits into real work
OWASP input-validation guidance is allow-list what you can, then parse with a real parser (URI, JSON, HTML). Regex is a filter, not a substitute for those parsers.
ReDoS (catastrophic backtracking) still takes down APIs. Avoid nested quantifiers on user-controlled input. If a pattern looks clever, it may be exponential.
Phone and postcode formats are national. A US-shaped pattern will reject valid AU numbers. Prefer a library (libphonenumber) when you actually dial.
How to use this tool
- Browse the categories to find a pattern close to what you need.
- Read the description and the example matches to understand its scope.
- Copy the pattern and test it against your own real inputs before relying on it.
Tips
- Email validation by regex is inherently approximate — the practical test is sending a confirmation message.
- Watch for catastrophic backtracking on nested quantifiers; it can hang a server on hostile input.
- Anchor patterns with ^ and $ when validating a whole value, or you may match only a fragment.
Privacy & how it works
Everything happens inside your browser. The values you type are held in page memory only, are never sent to a server, and disappear when you close the tab. You can confirm this in your browser's network tab: the only request a tool makes is one that names the tool for a usage count, with nothing you typed in it. The tools also work with the internet disconnected.
Frequently asked questions
- Why is email validation so hard?
- The formal specification permits quoted strings, comments, and unusual characters that almost no real address uses. Any practical regex trades strict correctness for readability, so confirmation email remains the real test.
- Do these patterns work in every language?
- Mostly. Core syntax is shared, but lookbehind, named groups, and Unicode handling vary between JavaScript, Python, PCRE, and Go. Test in your target environment.
Browse other tools
All tools run entirely in your browser — nothing you type is sent to a server, except the optional HIBP 5-character hash prefix.