Skip to main content
NeatUtility

JavaScript Regex Tester

Text100% Client-Side
Ready
REGEX
0 lines0 chars
0 B / 48.8 KB
About this tool, examples & FAQ

Test a JavaScript regular expression against sample text, inspect every match with capture groups and offsets, or substitute matches with group-aware replacement — with worker deadline protection.

Key facts

Verified capabilities and limits of this utility
InputsTwo panes: a pattern slot and a test-text slot
OperationsMatch with groups and offsets, boolean test, or group-aware replace
FlagsToggles for i, m, s, and u, unioned with inline flags; global matching is always on
Max input size500 KB
Execution deadline750 ms
Processing locationBrowser-only: pasted input is not uploaded

How to use

  1. Enter the pattern in the pattern pane and the sample text in the text pane.
  2. Pick Match, Replace, or Test Match as the operation.
  3. Set the flag toggles, or write inline flags with /pattern/flags notation.
  4. For Replace, set the replacement string using $1, $&, or $<name> tokens.
  5. Click 'Run' to execute the pattern inside a bounded worker.

Examples

Match foo with capture group

Input

(foo)
foo bar foo

Example output

--- Found 2 matches ---

Match 1 (index 0..3): "foo"
  Group 1: "foo"

Match 2 (index 8..11): "foo"
  Group 1: "foo"

Duplicate a capture with replacement

Input

(foo)
foo

Example output

foofoo

Edge cases

Unicode mode is on by default

The unicode toggle defaults to true, so some legacy patterns only compile with it disabled; inline u in /pattern/flags notation also enables it.

Zero-width matches

Zero-width matches advance safely, with surrogate-pair awareness, instead of looping forever.

Match cap

The match listing stops at a bounded count with an OUTPUT_TRUNCATED warning; the replace counting loop is not capped the same way.

How it works

  1. Parses /pattern/flags notation and unions inline flags with the option toggles.
  2. Compiles the JavaScript RegExp with global matching forced.
  3. Lists matches with offsets and numbered or named groups, or applies replacement tokens.
  4. Runs under a worker-level execution deadline so pathological patterns cannot freeze the tab.

Frequently asked questions

Which flags are available?

Case-insensitive (i), multiline (m), dot-all (s), and unicode (u) via toggles, unioned with any inline flags written in /pattern/flags notation. Global matching is always on with no toggle, and other inline flags are rejected explicitly.

How are capture groups shown?

Each match lists its offset range, the matched text, numbered groups in order, and any named groups by name. The example pattern (foo) reports Group 1 as foo for every match.

Will this pattern behave the same everywhere?

No. This tool uses JavaScript RegExp semantics, which differ from PCRE, Python, Go, and other engines in areas like lookbehind, named groups, and Unicode handling. Always test in the engine you will ship with.

Why does a pattern time out?

Catastrophic backtracking can make some patterns take exponentially long on innocent-looking input. Execution runs inside a worker bounded by the tool deadline, so the run fails safely instead of freezing the tab; simplify nested quantifiers to recover.

Which replacement tokens work?

Standard JavaScript replacement tokens such as $1 for numbered groups, $& for the whole match, and $<name> for named groups. The replacement $1$1 against one foo match produces foofoo.

How should I handle complex or untrusted patterns?

Keep patterns small, avoid nested unbounded quantifiers, and test against representative input with Unicode mode set as you will ship it. The worker deadline is a safety net, not a license to run adversarial patterns.

References