Skip to content
toolsdocks

Test a JavaScript regular expression

Enter a pattern, flags and test text to see every match and capture group, preview a replacement and read a plain-English explanation.

Runs on your device
Loading tool…

How to use

  1. Enter a pattern and flags.
  2. Type test text; matches are highlighted and groups listed.
  3. Try a replacement string with $1, $<name>.

Worked example

Pattern (\d{4})-(\d{2})-(\d{2}) with replacement $3/$2/$1 turns 2026-10-02 into 02/10/2026.

Supported formats and limits

InputPattern, flags, test text
OutputMatches, groups, replaced text
EngineBrowser RegExp in a Web Worker with a timeout to stop catastrophic backtracking

Limitations

  • This uses JavaScript regex syntax; PCRE features such as possessive quantifiers are not available.
  • The pattern explanation is a best-effort reading; your browser's RegExp engine decides what is valid and what matches.

Questions

Which regex flavour is used?

Your browser's JavaScript RegExp engine, with the d, g, i, m, s, u, v and y flags it supports. Patterns behave as they would in JavaScript code, which can differ from PCRE, Python or Java.

How does the replacement preview work?

It applies String.replace with your pattern and flags, so $1, $<name>, $& and $$ work as in JavaScript. (\d{4})-(\d{2})-(\d{2}) with $3/$2/$1 turns 2026-10-02 into 02/10/2026.

What if my pattern hangs?

Matching runs in a separate worker and is stopped after 1.5 seconds, so catastrophic backtracking shows a message instead of freezing the page. Up to 1,000 matches are listed.

Privacy

Runs on your device. Files and text are processed in this browser tab and are not uploaded.

See the privacy policy for how toolsdocks handles data.