I'm trying to capture several groups within a string and reorder them using a regex. However once I reach greater then 9 back-references, they do not replace as I expected.
Eg: This is a bit of a contrived example, but it should illustrate what's happening.
Input string: abcdefghij Find What: ^(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)$ Replace With: \10 Expected output: j Actual output: a0
I also tried:
Replace With: $10
Instead of \10
or $10
inserting the contents of the tenth grouping parens, it inserts the contents of the first grouping parens follower by "0".
UPDATE:
This does work using $10
in newer versions of Sublime Text, but it is way better to use the ${10}
syntax as described below.
Use:
${10}
I just tried it and that worked for me.
I also tried using find:
^(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)$
Replace with: $10
And it worked. I'm using v2.0.2 build 2221 however. The same with \10
doesn't work, but works as you described in your question.
It might be worth noting as well that many of the regex engines replace are shifting from the \#
format to the $#
format so that's maybe why $#
is working better for me even without braces.
Though now, if you wanted to replace with the 10th capture followed by a number (e.g. $100) the engine will look for the 100th capture group and for your example, will replace with nothing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With