Skip to content
Toolars
Explore

JavaScript Regex Tester

Test JavaScript regular expressions with capture-group inspection, exact match offsets, replacement preview, and a Worker timeout for expensive patterns.

Task path / input to outcome

Enter the pattern and flags

Report bug

Local processing

Processing details

Tool inputs are processed on your device.

Resources may be downloaded to run this tool. Account services are separate.

Preparing offline use…

Privacy information

Task path / input to outcome

How to test a JavaScript regular expression

  1. 01

    Enter the pattern and flags

    Type only the JavaScript pattern between the visible slash markers — up to 4,096 characters — and tick the flags you need: d, g, i, m, s, u, and y each carry an inline explanation. Duplicate or incompatible flag combinations are rejected with a named error. The workspace opens with a sample pattern that captures the protocol, host, and path of URLs through named groups, so there is a working example to build on.

  2. 02

    Paste the test text

    Paste or type up to 100,000 characters into the test text area. A paste triggers an immediate local check, while ordinary typing re-runs after a short pause whenever Auto-check is on; turn the toggle off and press Ctrl or Command plus Enter, or the Run button, to check on demand. The counter next to each label tracks the pattern and text length against their limits.

  3. 03

    Inspect matches and capture groups

    Matches highlight directly in the text — zero-width matches appear as markers at their position — and the result set is capped at 1,000 matches with a clear notice when the cap is hit. Select a match to see its exact UTF-16 start and end offsets, every numbered group, and every named group, including groups that did not participate. Previous, Next, Shift+F3, and F3 move through the set, and the summary line reports the match count and the run's duration in milliseconds.

  4. 04

    Preview JavaScript replacement syntax

    Open the Replacement preview tab and use JavaScript replacement tokens such as $1 or $<name> in a replacement of up to 20,000 characters. The preview follows native String.replace behavior exactly — including what an unmatched group inserts — and never modifies the source text, so you can iterate on the replacement without losing the original log or document.

  5. 05

    Recover safely from expensive patterns

    Each test runs in a disposable local Worker: startup is limited to 5 seconds, then execution to 650 ms. Cancel stops the Worker and auto-test while preserving input. Editing clears old results immediately; rerun to copy or download. A timeout or output-limit error can be recovered from by reducing the input, captures, or replacement and running again in a fresh Worker.

Tool facts

Processing
In your browser
Input leaves this device
Never
Retention
Nothing is stored
Price
Free

Your input stays in the browser.

JavaScript Regex Tester uses its verified local execution path and does not create a hidden input or output history.

Local execution

Runs inside the current browser tab.

No hidden processing

Active tool data never becomes a Toolars document record.

No account required

Use the core workflow without creating a profile. Favorites sync to your account after you sign in.

Immediate reset

Clear the tab and the active working data is gone.

What JavaScript Regex Tester actually does

An application log spans several hundred lines, and every URL in it must be extracted before a redirect rule ships. The sample pattern — named groups for protocol, host, and path — is a starting point: paste the log, watch each match highlight with its exact offsets, and open individual matches to check the host and path captures line by line. Then type $<protocol>://$<host> into the replacement field and confirm the preview strips paths exactly as intended before copying the tested pattern into the redirect code. The log never leaves the tab, which matters when it contains internal hostnames.

Common questions

Which regular-expression dialect is supported?
This release supports the JavaScript RegExp engine only, matching the behavior your pattern will have when it ships in JavaScript code. It does not claim compatibility with PCRE, RE2, Rust regex, Python, Java, or .NET, whose syntax and behavior can differ — a pattern ported from one of those engines deserves a fresh test here before reuse.
Which flags can I use, and what do they change?
The workspace exposes d, g, i, m, s, u, and y: d adds match indices, g finds all matches, i ignores case, m makes anchors match per line, s lets the dot cross newlines, u enables Unicode-aware semantics, and y anchors each attempt at the last position. Duplicate flags and incompatible combinations are rejected. The newer v flag is not exposed in this release so the tested surface stays consistent with the supported browser baseline.
What are the input limits?
Patterns allow 4,096 UTF-16 code units, input 100,000 and replacement templates 20,000. Only the first 1,000 matches are shown; the replacement preview still includes all matches within the budgets. Replacement output and retained match/capture text each allow 1,000,000 UTF-16 code units, with at most 20,000 numbered and named capture entries combined. Exceeding these budgets returns an error, without a partial export.
Can a catastrophic regular expression freeze the page?
Pattern execution is isolated from the interface in a dedicated Worker with a 650 ms reviewed timeout. A timed-out Worker is terminated and never reused, so the page stays responsive even when a pattern backtracks badly. This protects the page, but it is not a proof that a pattern is safe for every production workload — treat a timeout here as a warning worth heeding before shipping the pattern.
Why does my pattern fail with an error?
Enter the pattern body and choose flags separately. To test /abc/i, enter abc and select i. Pasting /abc/i into the pattern field does not automatically select i: it is a valid pattern containing literal slashes and the letter i, so it may produce unexpected matches rather than a syntax error. Invalid syntax is reported by the JavaScript engine; correct it and run again.
Are patterns or test text uploaded or saved?
No. Matching, group extraction, replacement preview, copy preparation, and validation run in the browser. Raw patterns, text, replacements, and results are not placed in URLs, analytics, logs, remote requests, or browser storage; clearing the workspace discards them.

Keep reading

Related tasks, not a dead end.

Move into another focused workspace without returning to the full index.

URL Workbench

Clean URL lists with signed-link protection and per-line reasons. Compare components and export sitemaps.

Edit

JSON Explorer

Query JSONPath, extract fields and round-trip JSON Pointer records without losing large-number precision.

Inspect

JSON Schema Validator

Validate Draft 7 or 2020-12 locally with exact error paths; infer schemas from multiple observed samples.

Inspect

HTML Publishing

Clean pasted HTML for publishing while preserving lists, links and table semantics; preview changes safely.

Publish