About this regex tester
This tester runs your pattern with the same regular expression engine your browser uses for JavaScript, so results match what you will get in JavaScript and TypeScript code and are close to PCRE, Python, and Java for everyday patterns. Every match is highlighted, capture groups get their own colors, and a table lists each match with its position and group values. Switch to Replace to try a replacement with $1, $2, or $<name> before you put it in your code, and read the explanation to see what each part of the pattern does.
How to test a regular expression
- Enter a pattern. Type a pattern without the surrounding slashes, or press one of the example patterns.
- Set flags and mode. Tick g to find every match, i to ignore case, and m, s, or u as needed. Choose Replace to try a replacement.
- Add test text. Paste the text to search. Sample text is already filled in for the examples.
- Press Test regex. See the number of matches, the highlighted text, each match with its groups, and the explanation of your pattern.
Frequently asked questions
Which regex flavor does this use?
JavaScript (ECMAScript), as built into your browser. It supports lookbehind, named groups, and Unicode property escapes such as \p{L} with the u flag. Features such as possessive quantifiers or atomic groups from PCRE are not available.
Why is only one match found?
Without the g (global) flag, a JavaScript regex stops at the first match. Tick g to find every match.
How do I use capture groups in a replacement?
Write $1 for the first group, $2 for the second, $<name> for a named group, $& for the whole match, and $$ for a literal dollar sign. For example, (\w+)@(\w+) replaced with $2 at $1 swaps the two parts.
Do I need to escape slashes?
No. Type the pattern without the /…/ delimiters, so a slash needs no backslash. Characters with a special meaning, such as . * + ? ( ) [ ] { } ^ $ | and \, need a backslash to match literally.
Why does my pattern freeze the page?
Nested quantifiers such as (a+)+ can take an extremely long time on some inputs (catastrophic backtracking). Make the inner part more specific or remove the nesting.