Repository navigation
Regex Tester: match table with groups, replace preview, cancellable runs - #27
Merged
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added
/pattern/flagsfills both fields@fadeltd/devtools-core/regexengine