mIRC Home    About    Download    Register    News    Help

Print Thread
#155153 04/08/06 12:45 AM
Joined: Aug 2006
Posts: 5
I
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Aug 2006
Posts: 5
6.2 problem:

when a backreference is covered by () in the subsitution parameter it returns an $<number> for each () ($1 and increasing for each other one).

(sorry if my explanation is poor, its best shown by example)

example:
echo -a $regsubex(ab,/(a)(b)/g,(\1)(\2))

echoed text:
($1)($2)


edit: its fine for 6.17



---
On a side note out of curiousity, why is there a limitation a dialogs edit box's number of characters? and is there any way to increase it?

Last edited by IRWolfie; 04/08/06 01:30 AM.

IRWolfie-
#irc @ GS
#155154 04/08/06 11:33 AM
Joined: Dec 2002
Posts: 5,443
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,443
In v6.17 $regsubex() was incorrectly parsing some combinations of characters, so bugfixes were applied to resolve these issues.

Basically: since the third parameter in $regsubex() is passed to the script parser, it needs to be formatted in the same way as normal commands/identifiers in order to ensure the required evaluation of its contents.

To resolve the issue you describe, you need to use something like //echo -a $regsubex(ab,/(a)(b)/g,( $+ \1 $+ )( $+ \2 $+ ))

#155155 04/08/06 12:32 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
The thing is that for most characters, \N markers don't behave quite like normal identifiers, e.g.
//echo -a $regsubex(ab,/(a)(b)/,<\1-+\2>)
echoes "<a-+b>" which means \1 and \2 are evaluated, even though they touch <, >, - and +.

Judging by the results of this: //echo -a $regsubex(a,/(a)/,$bits\1$bits)
which echoes "32a32"
and this: //var %z$1 = TEST | echo -s $regsubex(a,/a/,%z [\1 ])
which echoes "TEST" (meaning "%z [\1 ]" was interpreted as "%z [ $+ $1 ]")
it looks like mirc internally replaces strings like "foo\1bar" with something like "foo $+ $1 $+ bar". Can't this be made to work when foo = ( and bar = ) ?

I suspect (and this is just a guess) that ( and ) are excluded from this treatment because of their special role as parameter list delimiters in identifiers, but stuff like $upper( $+ $me $+ ) work fine already, so this special treatment may not be necessary

Last edited by qwerty; 04/08/06 12:46 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#155156 04/08/06 12:48 PM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
similarly:
//echo -a $regsubex(ab,/(a)(b)/g,$+ \t)
shouldnt try to run a command
* /returnexa: not connected to server

This was present in 6.17 as well but i forgot to bug report it frown

I quite like being able to have touching \N as replacement text though.


$maybe

Link Copied to Clipboard