Page 1 of 1

bug in backreferences replacement

Posted: Thu Feb 03, 2011 4:59 pm
by PaulD
Hi
Great application BTW, looking to replace Funduc S&R with this!

Using $1 in replacement string does not work if followed by a digit.

Example search text: "<idt>201002</idt>"

This works:
Search regex: "<idt>(\d{6})</idt>"
Replace regex: "<idt>$1xx</idt>"
Expected result: "<idt>201002xx</idt>"
Result: "<idt>201002xx</idt>"

This does not work:
Search regex: "<idt>(\d{6})</idt>"
Replace regex: "<idt>$101</idt>"
Expected result: "<idt>20100201</idt>"
Result: "<idt>$101</idt>"

Maybe the backreference matcher is looking for number 101 instead of number 1?

The same Regex works in Microsoft Word 2003 VBA, using Microsoft VBScript Regular Expressions 5.5 (vbscript.dll/3)

Tx

Posted: Thu Feb 03, 2011 8:20 pm
by DV
Yes, it's looking for 101 in that case.
You can put the number in braces-
eg:
<idt>${1}01</idt>

This will work now!

Glad you like the software!

Posted: Thu Feb 03, 2011 8:23 pm
by DV
Interestly, your broken example works if you put TextCrawler into ECMAscript compatible mode (eg The same as VBA/Javascript).

Posted: Wed Feb 09, 2011 5:17 pm
by PaulD
Great, both options work, thanks DV.