BUG: Replacement group should ignore consecutive digits

Tool for Search and Replace across multiple files.
Post Reply
SpringwellJames
Posts: 2
Joined: Mon May 18, 2015 11:45 am

BUG: Replacement group should ignore consecutive digits

Post by SpringwellJames »

If you enter a replacement string along the lines of $12$2 the output should be the first matched group followed by a 2 then the second matched group, but it is actually $12 followed by the second matched group. TextCrawler is incorrectly parsing the replacement string, presumably treating the $12 as group 12 rather than group 1 followed by a completely un-related digit 2.
User avatar
DigitalVolcano
Site Admin
Posts: 1717
Joined: Thu Jun 09, 2011 10:04 am

Re: BUG: Replacement group should ignore consecutive digits

Post by DigitalVolcano »

I think this is by design in the .NET regular expression engine.

More info here:
https://msdn.microsoft.com/en-us/librar ... x#Numbered


You can avoid this problem by putting braces around the group number:

Code: Select all

${1}2${2}
hope this helps!
SpringwellJames
Posts: 2
Joined: Mon May 18, 2015 11:45 am

Re: BUG: Replacement group should ignore consecutive digits

Post by SpringwellJames »

Yes, the braces fix it.

Thanks
Post Reply