mIRC Home    About    Download    Register    News    Help

Print Thread
#84326 27/05/04 10:58 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline OP
Hoopy frood
OP Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Code:
//echo -s $regsub(abc,b,[color:red]\[/color],%test) -> %test
//echo -s $regsub(abc,b,[color:red]\\[/color],%test) -> %test
//echo -s $regsub(abc,b,[color:red]\\\\\\\[/color],%test) -> %test

All echo "0 -> abc" where I hoped at least one of them would give me "1 -> a\c" or something like that.

However, if replace text is \\f or .\\ or anything that just does not consist entirely of backslashes, it gives the expected result of \ -> nothing and \\ -> \

I know a workaround, but that's not the point, is it?
Code:
//echo -s $regex(abc,^(.*?)b(.*)$) -> $regml(1) $+ \ $+ $regml(2)

#84327 27/05/04 11:20 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Looks like a bug.

As a simpler workaround than $regml() use a backreference to a non-existent match like this:
$regsub(abc,b, [color:red]\999\\,%test)[/color]


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#84328 28/05/04 08:03 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Indeed it is a bug (an old one too). The same thing happens with the $ char. In PCRE, $ is a special char, so one must escape it with \$. The bug is that \$ can be used in <subtext> only if there are other characters before or after it.

//var %a, %b = $regsub(abc,/b/,z\$,%a) | echo -a %a
works

//var %a, %b = $regsub(abc,/b/,\$z,%a) | echo -a %a
works

//var %a, %b = $regsub(abc,/b/,\$,%a) | echo -a %a
doesn't work

//var %a, %b = $regsub(abc,/b/,\$\$,%a) | echo -a %a
doesn't work


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#84329 04/06/04 07:03 AM
Joined: Dec 2002
Posts: 329
Fjord artisan
Offline
Fjord artisan
Joined: Dec 2002
Posts: 329
This should be fixed in the new mIRC 6.15
72.Fixed $regsub() handling of \ and $ characters.


Link Copied to Clipboard