{{ summaryTitle }}
{{ summaryValue }}

{{ summaryLine }}

Flags{{ summaryFlags }} Tested{{ summaryTested }} Guardrails{{ summaryGuardrails }}
{{ summaryAnnouncement }}
Regular expression test inputs
{{ sourceHint }}
Drop TXT, LOG, CSV, JSON, or Markdown onto the textarea.
{{ sourceError }}
Use the current browser's JavaScript regex dialect.
{{ patternError }}
Global or sticky matching lists repeated non-overlapping spans.
Leave blank to preview removal, or enter the exact replacement string to test.
Allowed range: 1 to 2,000.
matches
Allowed range: 50 to 5,000 ms. Raising it does not prove a regex is safe.
ms
Allowed range: 1,000 to 500,000 characters.
chars
{{ textExportAnnouncement }}
  • {{ warning }}
{{ tableExportAnnouncement }}
#MatchSpanLine:columnCapturesCopy
No matches for the current pattern and tested sample.
{{ row.number }}{{ row.match }}{{ row.span }}{{ row.position }}{{ row.captures }}
{{ chartExportAnnouncement }}

The chart renderer is unavailable. Match line evidence remains available in the ledgers.

{{ textExportAnnouncement }}
{{ replacementText }}

A regular expression can find a useful text shape and still be wrong for the job. A pattern that catches one valid identifier may also match a substring inside an invalid one. A pattern that works in a small sample may behave differently with another regex dialect, different flags, a much larger input, or a replacement string that interprets capture tokens.

JavaScript regular expressions operate on strings and return matches with positions and optional capture groups. Anchors restrict where a match may begin or end, character classes describe allowed characters, quantifiers control repetition, and groups preserve parts of the match for inspection or replacement. Flags then change the meaning of the same pattern by enabling repeated matching, case folding, multiline anchors, dot-all behavior, Unicode handling, indices, or sticky matching.

Evidence needed before trusting a regular expression
Test material What it reveals
Expected matches Whether the intended text is accepted and the right part is captured
Near misses Whether missing anchors, loose classes, or optional groups admit bad text
Empty, multiline, and Unicode cases Whether boundaries and flags behave as intended outside the simplest sample
Long adversarial input Whether nested alternatives or quantifiers create unacceptable execution time

Match success is not the same as validation. Searching for a date-shaped substring is different from requiring the entire field to be a real calendar date. Likewise, a replacement preview proves what the current JavaScript runtime produced for the tested text; it does not prove that another language, command-line utility, database, or production runtime uses identical syntax.

Performance needs its own check. Some patterns can take rapidly increasing time on carefully chosen input. A browser timeout limits one local test, but a quick result on one sample does not establish that the expression is safe for untrusted or much larger production data.

How to Use This Tool:

Build a small sample with both intended matches and realistic failures, then test the exact JavaScript pattern, flags, and replacement you plan to use.

  1. Paste text into Sample text or load one text-like file no larger than 4 MiB. Include near misses instead of testing only known-good lines.
  2. Enter the Pattern without slash delimiters, then select the JavaScript Flags. Use global or sticky when repeated non-overlapping matches are required.
  3. Add a Replacement only when substitution matters. An empty replacement previews removal; JavaScript replacement tokens such as $&, $1, $<name>, and $$ keep their normal meanings.
  4. Set the Match cap, Execution timeout, and Sample limit to keep evidence reviewable. If execution stops, reduce the sample or simplify the pattern before considering a larger timeout.
  5. Review the highlighted spans, match positions, captures, warnings, and replacement text. Treat truncation or cap warnings as incomplete coverage rather than a passing test.

Interpreting Results:

A matched result means at least one match occurred in the tested prefix. No match means none occurred there. Neither result says anything about characters beyond a reported sample limit.

  • Span gives the start and end offsets, while Line:column locates the match in the tested text. JavaScript string offsets count UTF-16 code units, so they may differ from user-perceived character counts.
  • Without g or y, JavaScript returns only the first match. Without d, capture values remain available but capture start and end indices are not.
  • Replacement text is the result of applying the same pattern and flags to the tested sample. Inspect it directly, especially when optional or named groups can be absent.
  • A timeout is a warning about this pattern and sample. A fast completion is not a security guarantee; repeat tests with realistic maximum sizes and hostile near-matches.

Technical Details:

The governing mechanism is a bounded JavaScript string transformation, not an arithmetic calculation. Pattern compilation, repeated matching, capture extraction, position mapping, and replacement all use the current browser's ECMAScript behavior.

Transformation Core:

  1. Whitespace is removed from the flag list, duplicate flags are collapsed, and flags are ordered as d g i m s u v y. The u and v flags cannot be combined.
  2. Only the leading Sample limit characters are tested. A warning records when the original input was longer.
  3. The pattern is compiled in an isolated browser task. Global or sticky expressions advance through non-overlapping matches; other expressions return at most the first match.
  4. Each match is projected into its text, span, line and column, capture values, and optional capture indices. Zero-width matches advance by one code unit so repeated matching cannot stay at the same position.
  5. A second expression with the same pattern and flags produces the replacement preview. The result is returned only if the isolated task completes before the timeout.

Rule Core:

JavaScript regular expression flag behavior
Flag Meaning in this test Important interaction
dExpose match and capture indicesNeeded for capture spans
gFind repeated non-overlapping matchesUses and advances the expression position
iIgnore case according to JavaScript rulesUnicode behavior can depend on the Unicode mode
mLet line boundaries affect anchors^ and $ can apply per line
sLet dot match line terminatorsCan broaden a pattern across lines
uUse Unicode-aware pattern semanticsMutually exclusive with v
vUse Unicode sets modeMutually exclusive with u and runtime support varies
yMatch only at the current expression positionRepeated sticky matching stops at the first gap
Regex tester validation and execution limits
Boundary Allowed range Behavior at the limit
Pattern length1 to 10,000 charactersEmpty or longer patterns are rejected
Loaded sample fileUp to 4 MiBLarger files are not read
Tested sample prefix1,000 to 500,000 charactersLater text is omitted and truncation is reported
Listed matches1 to 2,000Matching stops at the cap and a warning is added
Execution timeout50 to 5,000 msThe isolated task is terminated when time expires
Replacement lengthUp to 100,000 charactersLonger replacement input is rejected

The line chart displays at most the 24 lines with the most matches when more than 24 matched lines exist. The match ledger still keeps every listed match up to the selected cap.

Privacy and Accuracy Notes:

Pasted text and loaded files are read in the browser. Pattern execution takes place in an isolated local browser task that can be terminated at the selected timeout. Do not assume that local testing makes sensitive test data safe to copy into later reports or exports.

Results describe the current browser's JavaScript dialect. Port the test cases, not just the pattern, when moving to grep, PCRE, Python, .NET, a database engine, or another JavaScript version.

Worked Examples:

Anchoring a ticket code

Against lines containing OPS-2026 ready and OPS-20260 extra digit, the pattern OPS-[0-9]{4} matches both. Requiring a line start and a following space, such as ^OPS-[0-9]{4}[ ] with multiline mode, rejects the extra digit in this fixture.

Inspecting a named capture replacement

With a named group for a capitalized word and the indices flag enabled, the ledger can show the whole-match span and the capture span. A replacement such as [$&] then proves exactly which text is wrapped without changing unmatched text.