Pattern and text
Type a pattern to test it.
How to
Test a regex in three steps
- Enter the pattern and flags Type the pattern without slashes and choose flags such as i for case-insensitive or m for line-by-line anchors.
- Paste the text Matches update as you type. Each match shows its position and its numbered and named groups.
- Read the explanation A table breaks the pattern into parts with a plain-English meaning, and a warning appears for shapes that can run very slowly.
Writing safer patterns
- Avoid repeating a group that already repeats, such as (a+)+. On text that almost matches, the engine can take exponential time.
- Prefer specific classes like [0-9] or [^,] to a bare dot with a star.
- Anchor patterns with ^ and $ when you mean the whole text, and use the m flag for line by line.
- Add the u flag for emoji and other characters outside the basic range, so one character is counted as one.
FAQ
Regex tester questions
Which regex flavour does this use?
JavaScript, the same engine your browser uses. Features such as lookbehind and named groups work, but syntax from PCRE or Python may not.
Is my text sent anywhere?
No. The pattern and text are tested by code running in your browser, inside a background worker, and are never uploaded.
Why was my test stopped after two seconds?
Some patterns take exponentially longer as the text grows, which is called catastrophic backtracking. The tool stops them so the page stays usable.
What do the flags mean?
g finds all matches, i ignores case, m makes ^ and $ match at each line, s lets the dot match line breaks, u turns on full Unicode, y matches only at one position and d adds match indices.
How do I use groups in a replacement?
Write $1, $2 and so on for numbered groups, $<name> for named groups and $& for the whole match.
How many matches are shown?
The tool counts up to 1,000 matches and lists the first 200 in the table.