Task path / input to outcome
How to test a JavaScript regular expression
- 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.
- 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.
- 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.
- 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.
- 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.