DEVELOPER TOOLS

Regex tester●

Type a regular expression and some text, and see every match highlighted as you type.

Matches update as you type. Your pattern and text never leave this page.

Flags
Try an example

Matches

-

Your pattern and text are processed only in this browser tab. Nothing is sent, saved or tracked.

How to read and test regular expressions

A regular expression (regex) is a pattern that describes text. This tester runs your pattern with the JavaScript engine built into your browser, so it behaves exactly like regex in JavaScript, Node.js and most web code. Common building blocks: \d is a digit, \w a letter, digit or underscore, \s a space, . any character, ^ the start and $ the end of a line. Quantifiers say how many: * zero or more, + one or more, ? optional, {3} exactly three, {2,5} two to five. Square brackets match one character from a set, such as [a-z], and parentheses make a capture group you can reuse as $1 in a replacement. (?<name>...) makes a named group. Flags change the search: g finds every match instead of the first, i ignores case, m makes ^ and $ work per line, s lets the dot match a new line and u turns on full Unicode. Patterns that nest repeats, such as (a+)+, can take exponentially long on some text. This tester stops them after a moment instead of freezing your browser.

Find and replace →

Common questions

Which regex flavour does this use?

JavaScript (ECMAScript), because it runs in your browser. Most syntax is the same as in other languages, but features such as lookbehind, named groups and the s and u flags differ between engines.

Why does it only show one match?

Without the g flag a regex stops at the first match. Tick g to find all matches.

How do I use capture groups in the replacement?

Wrap part of the pattern in parentheses and refer to it as $1, $2 and so on. Named groups are available as $<name>, and $& inserts the whole match.

What does 'catastrophic backtracking' mean?

Some patterns with nested repeats try an enormous number of ways to match when the text almost fits. The tester stops the run after about a second and tells you, so your browser stays responsive.

Do I type the slashes around the pattern?

No. Type only the pattern, and choose flags with the checkboxes. The Copy regex button gives you the full /pattern/flags form.

Is my text stored?

No. The pattern and text are processed in your browser tab and are never sent or saved.