ONIGMO regex question...

Nov 8, 2015
24
1
#1
How can I use backreference less than 1 followed by a numeric character?? Suppose the regex is to insert 0 between a word and a dec number, for instance I'd replace bk391 to become bk0391. So set t=bk391 and command is
echo %@rereplace[^([a-z]+)(\d+),\10\2,%t]
will give ERROR instead of giving bk0391 as engine think I refer to a non-existent group of 10th captured group instead of the1st..
Please help me...many thankfulness in advance
 

ben

Jan 3, 2012
25
4
UK
#2
Enclose the back-reference number in curly brackets:
%@rereplace[^([a-z]+)(\d+),\{1}0\2,bk391]
or quote the zero with a caret:
%@rereplace[^([a-z]+)(\d+),\1^0\2,bk391]