The parsing of parameters in <subtext> is the same as with any other mirc identifier: $!identifier still evaluates to $identifier. However, $ is considered a special char in <subtext>: $1 is the same as \1, $2 = \2 etc:
//var %a, %b = $regsub(cd,/(.)/g,A$1B,%a) | echo -s %a
result: AcBAdB
Most probably, this feature has its roots to Perl. To escape $ in subtext, you use \$. Note that the \ in \$ident also prevents mirc from evaluating "$ident" simply because it touches the $, like it does in //echo -s \$me
Also note that
//var %a, %b = $regsub(cd,/(.)/g,A $1 B,%a) | echo -s %a
wouldn't give "A c BA d B" because mirc still evaluates <subtext>, as it does with all identifier params. So in this case, it would try to evaluate $1, which would be the first param passed to the calling routine (eg an alias or an event):
//tokenize 32 TEST | var %a, %b = $regsub(cd,/(.)/g,A $1 B,%a) | echo -s %a
To get it to work like the first example, you need to use $!1.
Last edited by qwerty; 05/03/05 09:48 PM.