mIRC Home    About    Download    Register    News    Help

Print Thread
#112602 25/02/05 05:34 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline OP
Hoopy frood
OP Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
I'll post it here first to see if I overlook something before deciding wether it's a bug or a 'missing feature'...


//var %r = blah, %x = $regsub(%r,(a),\13,%r) | echo -s result: %r

Does anyone know a way to have it return bla3h instead of blh?
More general: how to put a number immediately after a backreference in the substitution field?

Don't cheat by saying $regsub(%r,a,a3,%r) or the like, the given regex is an example smile

#112603 06/03/05 03:13 PM
Joined: Dec 2002
Posts: 1,253
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,253
//var %r = blah, %x = $regsub(%r,(a),\1_3,%r) | echo -s result: $remove(%r,_)
result: bla3h

The problem is that \13 is treated as a single number, the 13th capture (which is null in this case), so you're replacing the (a) with a null. The addition of a non-numeric character prior to the insertion solves that, and you can then remove it immediately prior to using it. If the text you're adding is non-numeric to begin with, it works fine.

//var %r = blah, %x = $regsub(%r,(a),\1#,%r) | echo -s result: %r
result: bla#h


Link Copied to Clipboard