mIRC Home    About    Download    Register    News    Help

Print Thread
#165617 28/11/06 02:08 PM
Joined: Feb 2006
Posts: 546
J
jaytea Offline OP
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
i've noticed an apparent bug when using $regsubex() inside another $regsubex()'s subtext parameter:

Code:
$regsubex(12345,/(\d)/g,X $regsubex(\1,/\d/,x) \1) = X x 1XXXX


the first round of substitutions works out alright (same happens with \t too) but the rest seem to be treating that inner $regsubex() and \1 as null

the expected result would be of course X x 1X x 2X x 3X x 4X x 5


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
#165618 28/11/06 05:27 PM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
it think this explains the problem:
//echo -a $regsubex(a,/(.)/,$(\1,0))
returns $1.

$regsubex(12345,/(\d)/g,X $regsubex(\1,/\d/,x) \1) = X x 1XXXX
will only work once because the 2nd regsubex tokenizes again leading to $0 being 0 and therefor \1 ($1) doesnt excist anymore when it does the substitution for 2.

//echo -a $regsubex(12345,/(\d)/g,X $regsubex(\1,/\d/,x) $(\0))
X x 5X 0X 0X 0X 0


$maybe
Joined: Apr 2005
Posts: 7
M
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
M
Joined: Apr 2005
Posts: 7
Assigning a name to the regex seems to solve the problem
Code:
$regsubex(main,12346,/(\d)/g,X $regsubex(nested,\1,/\d/,x) \1)


Link Copied to Clipboard