Regex Tester is a free tool for writing and debugging regular expressions. It highlights every match in your test text as you type, lists capture groups and their positions, and supports the i, m, s and u flags. It uses the JavaScript regex engine, runs in your browser, and stops runaway patterns before they can freeze the page.
How to test a regular expression
- Type a pattern in the top box, without the surrounding slashes.
- Paste text to search in the left box.
- Matches are highlighted on the right, followed by a list of each match with its position and groups.
Flags
- i: ignore case, so
catalso matches “Cat”. - m: multiline, so
^and$match at the start and end of every line, not just the whole text. - s: dot-all, so
.also matches line breaks. - u: Unicode mode, needed for
\p{L}(any letter) and to treat emoji as single characters. On by default.
Quick reference
\ddigit,\wletter, digit or underscore,\swhitespace,.any character+one or more,*zero or more,?optional,{2,4}between two and four times[abc]one of these characters,[^abc]anything else(…)capture group,(?<name>…)named group,(?:…)group without capturing\bword boundary,^start,$end
Slow patterns
Some patterns, such as (a+)+$, can take an astronomically long time on certain text because the engine tries every possible combination. This is called catastrophic backtracking and is a common cause of frozen web pages and server outages. The tester stops any pattern that runs longer than 1.5 seconds and tells you, so you can fix it before it reaches production.
To apply a pattern to text, use Find and Replace with regular expressions turned on.
Frequently asked questions
Which regex flavour does this use?
JavaScript (ECMAScript), as used in browsers and Node.js. Most syntax matches other languages, but features like lookbehind or named groups can differ from Python, PHP or Java.
Why was my pattern stopped?
Patterns with nested repetition, such as (a+)+$, can take practically forever on some text (“catastrophic backtracking”). The tester stops any pattern that runs longer than 1.5 seconds instead of freezing your browser.
Is the g flag needed?
The tester always finds every match. Choose the other flags (i, m, s, u) as needed.
Last updated