Better regex#2325
Conversation
Greptile SummaryThis PR refactors regex patterns across 15 files, making greedy quantifiers lazy (
Confidence Score: 5/5Safe to merge — all regex changes are either semantically equivalent refactors or genuine correctness improvements. Every change was verified against multiple input scenarios. The greedy-to-lazy switches in anchored patterns produce identical matches. The [\s\S] to [^] substitutions are identically equivalent in JavaScript. The lookbehind restructurings in editorFile.js, changelog.js, console.js, and rspack.config.js all preserve the original intent. The lazy fix inside the constructor parameter-list pattern in modify-java-files.js tightens correctness by preventing the pattern from spanning multiple method signatures. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Regex Changes in PR] --> B[Greedy to Lazy quantifiers]
A --> C[Character class equivalence]
A --> D[Lookbehind restructuring]
B --> B1[".* to .*? in anchored patterns"]
B --> B2["Genuine fix in getConstructorRegex"]
C --> C1["[\\s\\S] to [^] - Equivalent in JavaScript"]
D --> D1["Fixes Windows line-ending conversion in editorFile.js"]
D --> D2["Equivalent semantics in changelog, console, rspack"]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Regex Changes in PR] --> B[Greedy to Lazy quantifiers]
A --> C[Character class equivalence]
A --> D[Lookbehind restructuring]
B --> B1[".* to .*? in anchored patterns"]
B --> B2["Genuine fix in getConstructorRegex"]
C --> C1["[\\s\\S] to [^] - Equivalent in JavaScript"]
D --> D1["Fixes Windows line-ending conversion in editorFile.js"]
D --> D2["Equivalent semantics in changelog, console, rspack"]
Reviews (2): Last reviewed commit: "Update editorFile.js" | Re-trigger Greptile |
|
Fixed the problem the... summary pointed out. |
|
however, I cannot garantee they are 100% better or not-breakers without string contexts. For example If you have these regexes:
and this string: The first one(1) will match The second one(2) will match only The advantage of the lazyfication is that it prevents backtracking. ANOTHER case where |
Better regex