Skip to content
beginthings.

Dev & Data

Regex tester

Type a pattern and some test text to see every match highlighted, with each capture group in a table. Try a replacement too. Your text never leaves this device.

Pattern

Write the pattern without the slashes. /pattern/ pasted from code also works.

Test text

Use $1, $2 for numbered groups, $<name> for named groups and $& for the whole match.

Result

How to use this tool

  1. Type your regular expression, without the surrounding slashes.
  2. Tick the flags you need, such as global, ignore case or multiline.
  3. Paste the text to test and read the highlighted matches and the group table.
  4. Optionally tick replace, enter a replacement and copy the result.

How it works

The tester uses the regular expression engine built into your browser, the same one JavaScript code uses, so a pattern that works here works in your script. Each match is highlighted in the text, and the table lists its position, the full match and every capture group, including named groups written as (?<name>...).

Matching runs in a separate background worker. If a pattern takes too long, usually because nested quantifiers such as (a+)+ make the engine try millions of paths, it is stopped after a second and a half instead of freezing the page.

Good to know

Some quick reminders: \d is a digit, \w a letter, digit or underscore, and \s any space. + means one or more, * zero or more and ? optional. Add ? after a quantifier to make it lazy, so it matches as little as possible. Square brackets list allowed characters, and a caret inside them, as in [^0-9], means "not these".

Other languages have small differences. Python and PCRE support possessive quantifiers and some extra syntax, while JavaScript supports lookbehind only in modern browsers. Test with the same engine your code will use. Because everything runs locally, you can safely test patterns against logs or customer data.

Frequently asked questions

Which regex flavour does this use?

JavaScript (ECMAScript) regular expressions, exactly as your browser runs them.

Why does it only find one match?

Without the global (g) flag a JavaScript regex stops at the first match. Tick Global to find them all.

Why was my pattern stopped?

It took longer than a second and a half, which usually means catastrophic backtracking. Make quantifiers more specific or avoid nesting them.

Can I paste /pattern/gi from my code?

Yes. The slashes are removed. Set the flags with the tick boxes.

Is my text uploaded?

No. Matching happens on your device.

More free tools you might need