Goal
Add a -e / --regex flag that treats the pattern as a regex (RE2 syntax) instead of a literal string. Capture groups in the replacement work via the standard $1, ${name} syntax.
find-replace -e '(\w+)_test\.go' '$1.test.go'
find-replace -e 'github\.com/old/(\w+)' 'github.com/new/$1'
Default stays literal
Literal mode remains the default. Switching the default to regex would silently break any existing invocation whose pattern contains ., +, *, ?, (, [, \, etc. — that's most real-world patterns (filenames, version strings, URLs). Opt-in keeps every existing script working.
Why this triggers a major release (v2.0.0)
Even though the default doesn't change, this is the natural breakpoint for the regex feature set:
- New flag surface (
-e/--regex) and new replacement syntax ($1, ${name}, $$)
- Combined with the prerequisites below, this is a substantial expansion of what the tool does
- v2.0.0 gives a clean documentation cut and a clear "before/after" for users reading the README
The major bump is more about communicating the scope of new capabilities than about breaking changes.
Depends on (must land first)
Acceptance
Goal
Add a
-e/--regexflag that treats the pattern as a regex (RE2 syntax) instead of a literal string. Capture groups in the replacement work via the standard$1,${name}syntax.Default stays literal
Literal mode remains the default. Switching the default to regex would silently break any existing invocation whose pattern contains
.,+,*,?,(,[,\, etc. — that's most real-world patterns (filenames, version strings, URLs). Opt-in keeps every existing script working.Why this triggers a major release (v2.0.0)
Even though the default doesn't change, this is the natural breakpoint for the regex feature set:
-e/--regex) and new replacement syntax ($1,${name},$$)The major bump is more about communicating the scope of new capabilities than about breaking changes.
Depends on (must land first)
s/foo/bar/over a tree with both names). The safety substrate must be in place before regex mode goes live.--rename-onlyand--content-onlyscope flags #36 —--rename-only/--content-onlyscope flags. Regex patterns often want to target one half (e.g. rename files by pattern without scanning every file's contents). Scope flags need to exist before users start writing regex invocations.Acceptance
-e/--regexflag added; literal stays default$1,${name},$$(literal$),$0(whole match)2.0.0--rename-onlyand--content-onlyscope flags #36, Build regex engine with capture-group replacement support #37 are merged