Regex Tester
Test JavaScript regular expressions live, see every match and group, and try replacements.
/
Matches highlighted
| # | Match | Position | Groups |
|---|---|---|---|
|
JavaScript literal:
Cheat sheet
. | Any character except a new line |
\d \w \s | Digit, word character, whitespace (capitals mean "not") |
[abc] [^abc] [a-z] | One of, none of, a range |
* + ? {2,5} | 0 or more, 1 or more, optional, between 2 and 5 times |
*? +? | Lazy versions: match as little as possible |
^ $ \b | Start, end, word boundary |
(…) (?:…) (?<name>…) | Capturing, non-capturing and named groups |
a|b | Either a or b |
(?=…) (?!…) (?<=…) (?<!…) | Lookahead and lookbehind |
Regex Tester
Write a regular expression and see immediately what it matches in your test text: every match is highlighted and listed with its position and capture groups, including named groups. Switch flags on and off, try a replacement string with $1 or $<name> references, and look up syntax in the built-in cheat sheet. Patterns run in a background worker, so a runaway pattern cannot freeze the page.
How to use Regex Tester
- Type the pattern, without the surrounding slashes.
- Choose the flags: g for all matches, i to ignore case, m for multi-line anchors, s for dot-all, u for Unicode.
- Paste the test text and look at the highlighted matches and the table of groups.
- Optionally enter a replacement to preview the result.
When it comes in handy
- Building patterns for form validation, log parsing or search and replace.
- Debugging why a regex does not match.
- Learning regular expressions.
Frequently asked questions
- Which regex flavour is this?
- JavaScript (ECMAScript), as used in browsers and Node.js. Most syntax is shared with PHP (PCRE), Python and Java, but some features, such as possessive quantifiers, differ.
- What happens with catastrophic backtracking?
- Matching stops after two seconds and the tool tells you the pattern took too long, instead of freezing your browser.