Regex Tester (JavaScript)

Test JavaScript regular expressions with highlighted matches, numbered and named groups and a replace preview. Patterns that run too long (ReDoS) are stopped automatically.

  • Runs in your browser (no upload)

No surrounding slashes. Examples: \d+, (?<year>\d{4})

Flags

You can use $1, $<name>, $& (whole match) and $$ (a literal $).

Patterns up to 1,000 characters, test strings up to 100,000 characters. Runs longer than 1 s are stopped automatically.

Running…

How to use

  1. Enter a pattern and choose flags such as g, i or m.
  2. Type a test string: matches are highlighted and listed with their positions and groups.
  3. Enter a replacement (with $1, $<name> and so on) to preview and copy the replaced text.

FAQ

Which regex engine is used?

Your browser's JavaScript engine (RegExp). Some syntax and behavior differ from PCRE, Python or Java.

Can a bad pattern freeze the page?

No. Matching runs in a separate Web Worker; if it takes longer than 1 second the worker is stopped and you see a "took too long" message, even for catastrophic backtracking such as ^(a+)+$.

What about patterns that match an empty string?

After an empty match the search moves on to the next position (by whole characters with the u or v flag), so it never loops forever.

Notes & limitations

  • What you enter is processed only on this page and is not sent to YUCTS servers.
  • Patterns are limited to 1,000 characters and test strings to 100,000 characters. Only the first 1,000 matches are highlighted and listed.
  • Available syntax and flags (such as v and d) depend on your browser version; unsupported flags are disabled.
  • The 1-second limit depends on device speed, so a slow device may stop an ordinary pattern too.
  • Safari (JavaScriptCore) stops a search by itself after too much backtracking and reports "no match". This tool warns about slow runs but cannot tell whether such a result is correct.

Data sources