Closed Mango0x45 closed 2 years ago
This is in fact supported via Go's regular expression syntax. You can use s/(.)/$1$1/
for example. You can read about the regex syntax here: https://pkg.go.dev/regexp/syntax, and about the expansion syntax here: https://pkg.go.dev/regexp#Regexp.Expand.
Ah that makes a lot of sense. Thanks!
is there a way to just print the capture group? something like 'g/hello ([a-z]+)/c/$1/'
which would print world
when inputted hello world
PS: why doesn't \w work?
Adding support for capture groups would make certain tasks much easier. For example, what if I wanted to duplicate every character? With regular
sed
this is as easy ass/./&&/g
, or more explicitlys/\(.\)/\1\1/g
. I have not found a way to achieve this withsregx
yet though (without the use of/u/
that is).