and I want replace the digits (123 in this case) with 3 other digits (456 in this case) every time they follow “abc” and precede “xyz”
So my search pattern is:
(abc)(\d*)(xyz)
So I want the 1st subexpression followed by “456” followed by the 3rd subexpression…
But if I use:
\1456\3
RegEx seems to think that I want the 1456th subexpression followed by the 3rd subexpression and I get junk.
If I use:
\1 456 \3
it works but I get extra spaces that I do not want.
Actually, I am over simplifying this at bit since the “abc” pattern in my actual case has wildcards… it is more like “a.*c”… which is why I have to define it as a subexpression so I can carry it into the resulting replacement string.
So how do you refer to a subexpression in the replacement pattern when it is followed by an integer?
RegExRx is a handy tool. Grouping did not work (I ended up with literal parenthesis in the result). For whatever reason, using the “complete match” thing made it work. I’m not certain why, Kem might know, but it does happen to work as you desire:
Replacement Pattern: $&1456$&3
[quote=392984:@Tim Parnell]RegExRx is a handy tool. Grouping did not work (I ended up with literal parenthesis in the result). For whatever reason, using the “complete match” thing made it work. I’m not certain why, Kem might know, but it does happen to work as you desire:
Replacement Pattern: $&1456$&3[/quote]
Well this does not seem to work in 2017r2.1… back to the drawing board.