Regex Tester
Test and debug regular expressions with live highlighting and capture groups.
How to use: Type a pattern and some test text. Matches are highlighted as you type.
Highlighted matches
How to use the Regex Tester
A regular expression is a compact pattern for finding text. Developers use them to validate emails and phone numbers, search logs, clean data and rewrite text in bulk. They are powerful, but easy to get subtly wrong, which is why instant feedback is so valuable.
Type your pattern between the slashes and put some sample text in the test string. Every match is highlighted immediately, and the table lists each match with its position and the contents of every capture group. Use the flag checkboxes to switch on global matching, case-insensitivity, multiline mode, dot-matches-newline and Unicode mode. This tester uses your browser’s JavaScript regular expression engine, so results match what you will get in web and Node.js code.
To preview a find-and-replace, type a replacement string. Use $1, $2 and so on to insert capture groups, and $& for the whole match. Named groups, lookaheads and lookbehinds are supported wherever your browser supports them.
If the pattern is invalid, the browser’s error message is displayed. Beware of nested quantifiers such as (a+)+, which can cause catastrophic backtracking and freeze the page on certain inputs. Start with a simple pattern, test it on a few examples, then refine it step by step.
Frequently asked questions
Which regex flavour does this use?
JavaScript (ECMAScript). Most basic syntax is shared with other languages, but features such as lookbehind and named groups differ between engines.
Why do I only see one match?
Switch on the “g” (global) flag to find every match instead of just the first one.
How do I insert a captured group in the replacement?
Use $1, $2 and so on, or $