Repository navigation
Add the rr object, pad() and print() to --js to close #856 - #861
Merged
Merged
Conversation
This was referenced Oct 27, 2026
mathiasrw
added a commit
that referenced
this pull request
Oct 27, 2026
…mment also runs the code per match
mathiasrw
added a commit
that referenced
this pull request
Oct 27, 2026
* Add Regex+ engines, with rr as the default engine * Make regex+ the Regex+ engine with v, x and n, add regex+n and regex+x, and drop regex+u * Add --flags, keep only regex+ with v, x and n, and name the groups of --js $year * Check --flags against the flag options in the CLI, take v for regex+ by default, and warn on $1 under n * Name the unknown flags of --flags, and check the messages of the stopped runs in the tests * Take regex from npm and copy only its subroutines, drop V8, JSC, V and the $1 warning, and fix [(?>]\1 * Run --js code that runs once per file at its first match * Add the rr object with long names, print(), printErr(), pad() and file_path to --js * Build RexReplace as an ES module, and the engine also as CommonJS * Say in src/libs that regex is imported, not bundled * Load yargs as CommonJS so the help breaks at words, and use the require of the CommonJS build, not the path of the build * Let a group named like a cousin win in any order, and say that only --js code has no $1 under n * Leave the README row of --js to #861, which changes it too * Add the rr object with long names, print(), printErr(), pad() and file_path to --js * Tell that functions have no _ cousin, and that rr in a string or a comment also runs the code per match * Say in the README that only --js code has no $1 under n * Show the \\n in the help of --status as text, and bring the README row of --debug in line with its help
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.
Closes #856
Stacked on #860. In place of #857, after the review of 26 October.
Change
rrhas the values of RexReplace with long names, directly on it:filePath,filePathRel,dirPath,dirPathRel,dirName,fileName,name,ext,bytes,size,mtime,ctime,mtimeObj,ctimeObjfileNumber($n),filesTotal($t),matchedFileNumber($i),changedFileNumber($c),matchThisFile($m),matchUntilNow($M)text,find,stdin(the piped data),cwd,time,timeObjrr[0],rr[1]andrr.year, which overwrite a name they shareprint()andprintErr(), also asrr.print()andrr.printErr(), print to stdout and stderr with a line break, also with--quiet-total.print()withoutrrruns once per file, so it can print once for a file.pad(value, width = 3, char = '0'), likepad($1)for007.file_pathandfile_path_rel, the same asfileandfile_rel, with their space cousins.rrruns once per match, as it can reach a group in a way the search of the code can not see, likerr[name].rris found as a whole word, so{...rr}andconst r = rrcount too, andbrrdoes not.rris a plain object: every value is its own, so{...rr},Object.keys(rr)andJSON.stringify(rr)have them all. It is only made when the code namesrr, and the values of the file are made once per file. 20 000 matches:$1.toUpperCase()takes 205.5 ms, andrr[1].toUpperCase()205.6 ms.Tests
test/fix/856.test.jsis new, and 15 of its 17 tests fail without the change. It covers the groups by number and by name, the long names of a file and of the numbers over three files,text,find,cwd,time,stdin, a group that overwritesrr.name, a spread ofrr, the run per match, thatbrr.nis notrr,print,rr.print,printErrandrr.printErrwith--quiet-total,pad(), andfile_path. The help and the README tell all of it.yarn test-cipasses.From the code review of #855
The README row of
--jssays that under the flagnonly the code has no$1, while a replacement text still reads$1as the first named group. It is here, as this pull request changes that row too.