Skip to content

Regex Tester: match table with groups, replace preview, cancellable runs - #27

Merged
fadeltd merged 1 commit into
mainfrom
feat/regex-tester
Oct 30, 2026
Merged

fadeltd merged 1 commit into
mainfrom
feat/regex-tester

Conversation

@fadeltd

@fadeltd fadeltd commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Added

  • Regex Tester: every match with line, column and named or numbered groups; click a row to select it in the text
  • Replace preview with a replacement count and warnings for references that do nothing
  • Flag toggles; pasting /pattern/flags fills both fields
  • Runs in a worker, with Cancel for slow patterns
  • @fadeltd/devtools-core/regex engine

… in a worker

New core subpath /regex: compileRegex and checkFlags return errors as data (without the engine's echo of the whole pattern), parseRegexLiteral splits a pasted /pattern/flags, captureGroupNames numbers groups as the engine does (escapes, classes, v-mode nested classes, lookarounds, duplicate names). findMatches follows JavaScript exactly (all matches with g, the first without, empty matches stepping a code point under u/v, g+y stopping at the first gap) with line, column and group spans via d, capped at 10,000. replaceWith is String.prototype.replace plus a count, through expandTemplate, a copy of GetSubstitution; replacementIssues flags references that silently do nothing ($3 past the last group, $0, unknown $<name>, \1). Property tests check findMatches against matchAll and replaceWith against the native replace over generated text and templates.

The tool runs everything, compiling included, in regex.worker.ts via useWorkerJob, so (a+)+$ leaves the page responsive and offers Cancel after 2 s. Match mode shows a virtualised table (line:col, match, groups by name or number, a group that did not take part as —); clicking a row selects the match in the text. Replace mode previews the output with a count and the reference warnings. Flags are toggle buttons (u and v exclude each other). Route chunk 4.2 kB gzip, worker 3.7 kB; first-load JS +263 B for the registry entry.

useNarrow moves from the JSON tool to src/lib/util so a second route can use it without a cross-route import.
@fadeltd
fadeltd merged commit d803231 into main Oct 30, 2026
1 check passed
@fadeltd
fadeltd deleted the feat/regex-tester branch October 30, 2026 04:30
@fadeltd fadeltd changed the title Regex Tester (B-8): matches with groups, replace preview, worker with Cancel Regex Tester: match table with groups, replace preview, cancellable runs Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant