What you can do with Regex Tester & Pattern Library
- Test regex against text
- Find pattern matches
- Browse common regex patterns
How this text processing works
Choose from seven built-in JavaScript regex patterns or write a custom expression, test it against text, and inspect each full match and its start index.
Example input
Pattern: \d+, flags: g, text: a1b22Example output
[1] 1 and [3] 22 — each match listed with its zero-based start indexPractical workflow
- Choose one of the seven starter patterns from Pattern library, or type a JavaScript expression without surrounding slashes.
- Set flags in the separate field: g lists every match, i ignores letter case, m changes line-anchor behavior, s lets a dot match line breaks, and u enables Unicode mode.
- Enter sample text and select Test Regex; each full match appears as [index] text, or the result shows <none>.
- Review the selected preset's description and limits, then copy the pattern when it fits your use case.
Common use cases
- Start with the email, URL, US phone, date-shape, IPv4, hex-color, or password example before adapting a validation expression.
- Find the character offsets of matching IDs, digits, or other tokens in a log line or pasted text sample.
- Compare global and single-match behavior while learning how JavaScript flags affect a pattern.
Important notes and limitations
- Matching runs in your browser with the JavaScript RegExp engine, so results reflect JS semantics — not PCRE, Python, or Java.
- Without g, the tester reports the first match only. A missing g flag is valid and is not an error.
- The seven library entries are starter patterns, not complete standards validators. In particular, the date expression checks YYYY-MM-DD shape but can match an impossible calendar date; the email and URL expressions also have format limits.
- The password pattern checks for at least eight characters with an ASCII letter and digit; it does not measure strength or check breached-password lists.
- Only the full match and its zero-based start index are shown; capture groups are not broken out. Patterns run in a Web Worker with a 2-second deadline, pattern and text limits of 2,000 and 100,000 characters, and a 10,000-match result cap. A timed-out worker is stopped without blocking the page.
Terminal & CLI equivalents
ripgrep fast regex search
rg -P "(?<=id=)\d+" server.logLightning-fast grep alternative with PCRE2 lookaround and regex support.
GNU grep with PCRE pattern
grep -P -o "^[A-Z][a-z0-9_]+" data.txtMatches Perl-compatible regular expressions directly in Linux shell environments.
Regular Expression Engine Dialect Matrix
| Feature | JavaScript (ECMA-262) | PCRE2 (PHP / grep -P) | Python (re module) | Go (RE2) |
|---|---|---|---|---|
| Lookbehind Assertions | Yes (ES2018+) | Full variable support | Fixed length only in std re | No support (RE2 design) |
| Named Capture Groups | (?<name>pattern) | (?P<name>pattern) | (?P<name>pattern) | (?P<name>pattern) |
| Possessive Quantifiers | No | Yes (e.g. a++) | In regex module | No |
| ReDoS Catastrophic Backtracking | Vulnerable (NFA) | Vulnerable unless JIT | Vulnerable (NFA) | Immune (Linear time guarantee) |
Common errors & troubleshooting
Catastrophic Backtracking / Regular Expression Denial of Service (ReDoS)
Cause: Nested quantifiers such as (a+)+$ cause exponential branch exploration on non-matching inputs.
Solution: Refactor patterns into non-overlapping character classes or atomic groupings.
Continue your workflow
- Regex Visualizer — visualize regular expressions as state transition railroad diagrams.
- String Escaper — escape regex special characters for safe inclusion in programming code.
- Diff Checker — verify regex replacement outputs side by side with original inputs.
- Text Utilities — clean and transform text strings with case conversion and trimming.
Frequently asked questions
Why do I get “Invalid regex” for a pattern that works elsewhere?
The pattern may use syntax unsupported by JavaScript or by the browser's RegExp version, or the flags may be invalid or repeated. The g flag is optional; without it the tool reports only the first match.
Do I need to include the slashes?
No. Enter only the pattern, for example \d{4}-\d{2}, and put the flags in the separate field.
Do the date and email presets validate every possible value?
No. They are starter expressions. The date preset checks string shape but not calendar validity, and the email preset does not cover every address allowed by email standards.
Does the result show captured groups separately?
No. Results list each whole match and its zero-based start index; capture-group values are not displayed as separate rows.