What this tester executes
The pattern is compiled by the current browser’s native ECMAScript regular-expression engine. That gives the page the same syntax and semantics as JavaScript running in that browser: numbered and named captures, lookahead and supported lookbehind, Unicode property escapes, replacement tokens and the flags implemented by the runtime. It does not translate patterns between languages.
Engine labels matter. A construct accepted by PCRE may be a syntax error in JavaScript; a JavaScript backreference or lookbehind may not be supported by RE2; Unicode data can differ between runtime versions. Re-test in the exact production language and version before treating a browser result as portable.
Why matching runs in a disposable worker
Backtracking regex engines can take dramatically longer when nested alternatives or quantifiers explore many failing paths. JavaScript does not provide a built-in time budget for one RegExp.exec call. Running that call on the main thread can freeze typing, scrolling and the stop controls themselves.
This workbench creates a dedicated Web Worker for each run. The page terminates it if no result arrives before the selected deadline and destroys it after a successful or failed run. This contains one test’s CPU work away from the interface. It is a testing boundary, not a static complexity analyzer: a pattern that finishes quickly on 100 characters can still behave badly on a crafted 100,000-character string.
Flags change both matching and iteration
- d asks the engine for start/end indices for the full match and captures.
- g continues searching after a match; without it, normal execution returns the first match only.
- i enables case-insensitive matching according to the engine’s rules.
- m changes
^and$so they can match around line terminators. - s lets dot match line terminators.
- u enables Unicode-aware parsing and code-point behavior.
- v enables Unicode sets and is mutually exclusive with
u. - y makes the match sticky at
lastIndexinstead of searching forward.
When a global or sticky pattern matches an empty string, a manual collection loop must advance explicitly. This implementation advances one Unicode code point under u/v, otherwise one UTF-16 code unit, and represents the zero-length result with an ∅ marker.
Reading matches and capture groups
Start and end are zero-based UTF-16 code-unit offsets, matching JavaScript string indexing. Line and column are one-based conveniences derived from the same start offset. A visible emoji can occupy two UTF-16 units; combining sequences can occupy several code points. Do not reinterpret these offsets as grapheme counts.
Numbered captures appear in opening-parenthesis order. Named captures appear under their declared names. An optional group that did not participate is reported as undefined rather than as an empty string. With the d flag, downloaded JSON also contains capture ranges when the browser supports them.
Replacement syntax is not template interpolation
JavaScript replacement strings recognize tokens including $$ for a dollar sign, $& for the full match, $1 through $99 for numbered captures, and $<name> for named captures. They are interpreted by String.prototype.replace; JavaScript template-literal syntax such as ${name} is unrelated. The global flag controls whether all matches or only the first are replaced.
A safer production regex workflow
- State which engine and runtime version will execute the pattern.
- Test expected matches, expected non-matches, empty input and newline behavior.
- Add long near-miss strings designed to make the pattern fail late.
- Bound input length before matching when the application can do so.
- Avoid presenting a client-side timeout as proof of linear performance.
- For untrusted patterns or high-consequence services, use an engine or architecture with an enforceable resource boundary.
Privacy and export boundary
Pattern, test text, captures and replacement output stay in the tab. The share URL includes only pattern and flags, never test or replacement text. JSON export is explicit and includes matched substrings and captures, which may contain sensitive material from the test input; inspect the file before sharing it. Browser extensions and clipboard or download history remain outside this page’s control.
Standards and implementation references
Editorial and implementation review: 2026-08-02. Syntax errors, flags, captures, named groups, indices, Unicode empty matches, replacement tokens, truncation limits, worker assets and page structure are covered by deterministic tests.
Frequently asked questions
Which regular-expression engine does this use?
The workbench uses the native JavaScript RegExp implementation in your browser. JavaScript syntax and behavior can differ from PCRE, Python, RE2, .NET, Java and other engines.
Can a regular expression freeze the page?
A pattern with catastrophic backtracking can consume substantial CPU. Matching and replacement run in a dedicated Web Worker; the page terminates that worker at the selected deadline. A timeout reduces UI lockups but does not prove a pattern is safe for production.
Why does a valid pattern fail with the v flag?
The Unicode sets v flag is newer than the traditional u flag and may not be supported by an older browser. The native engine returns its own syntax error. The u and v flags cannot be enabled together.
Why do I get only one match?
Without g, JavaScript RegExp execution stops after the first match. The sticky y flag can continue only where the previous match ended. Enable g for a normal find-all workflow.
How are empty matches handled?
A valid regex may match an empty string. The worker advances by one UTF-16 code unit, or one Unicode code point in u/v mode, so the collection loop cannot repeat forever at the same position. Empty matches appear as an ∅ marker.
Is my pattern or test text uploaded?
No. Pattern execution, capture inspection, replacement and JSON generation happen in this tab. Share links contain only the pattern and flags; they intentionally omit test and replacement text.