On 3/16/22 at 2:06 PM,
thep...@gmail.com (ThePorgie) wrote:
>I was tinkering with with Patrick's question
Not actually my question ;-) though close enough for the matters
at hand.
>So I was looking at this and knew it would have to be several
>passes, but my pattern I was working with for the first pass
>was "(?P<foo>\d+\.)1"
>
>My question is since I can't use a replace pattern \1 follow by 33
You can in fact do this by prefixing a zero "0" to the singular
backreference number, so:
Replace: \0133
will give you the first backreference \01 followed by the string "33".
>I was using a named pattern, but (?P=foo) doesn't call the named pattern
>in the replace area of a grep search? Just curious as I couldn't find
>anything regarding this in the manual.
Please see the section titled "Subpatterns Make Replacement
Powerful" in Chapter 8 (page 202) of the current manual:
Pattern Inserts
=====================================================
[...]
\P<NAME> the text matched by the subpattern NAME
Regards,
Patrick Woolsey
==
Bare Bones Software, Inc. <
https://www.barebones.com/>