mIRC Home    About    Download    Register    News    Help

Print Thread
regsub vartext backreferences followed by digits #39559 04/08/03 02:43 AM
Joined: Dec 2002
Posts: 17
KyD Offline OP
Pikka bird
OP Offline
Pikka bird
Joined: Dec 2002
Posts: 17
$regsub(test,abc,(b|d),\12,%var)
the intention here is to put the digit '2' behind the first 'b' or 'd' in a string.

the regsub above won't work because mirc interprets "\12" as the 12th backreference, not as the 1st followed by the digit '2'.

is there a way of getting around this?

Re: regsub vartext backreferences followed by digits #39560 04/08/03 02:51 AM
Joined: Dec 2002
Posts: 17
KyD Offline OP
Pikka bird
OP Offline
Pikka bird
Joined: Dec 2002
Posts: 17
oops double thread, we had a misunderstanding in who was to post the question here on the forum.
sorry about this.

Re: regsub vartext backreferences followed by digits #39561 04/08/03 03:05 AM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
I didn't really think about it much, but it seems mIRC doesn't allow _any_ regex features in the "replace with" part other than \#, so the only thing I could come up with is something like:

$regsub(test,abc,(b|d),\1 $+ $chr(255),%var)
%var = $replace(%var,$chr(255),2)

Since character 255 is the character for the delete key, you can be reasonably sure that will not appear in your text. It's not a good way to do it, but it works.

Re: regsub vartext backreferences followed by digits #39562 04/08/03 09:52 PM
Joined: May 2003
Posts: 215
lammkott Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2003
Posts: 215
Quote:
Since character 255 is the character for the delete key...


$chr(255) on fonts like Tahoma is a and on fonts like Terminal it's a non-breaking space. That's how mIRC returns it anyway.


- Jason
Re: regsub vartext backreferences followed by digits #39563 04/08/03 09:56 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Err indeed, you're right, no idea why I said 255, I meant 127

Re: regsub vartext backreferences followed by digits #39564 04/08/03 09:56 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Depending on the purpose of this, it could be better to use a character that cannot be in IRC text. Most of the times I use $lf or $cr.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: regsub vartext backreferences followed by digits #39565 04/08/03 11:54 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
if \999 is the maximum matches so why \1\9992 doesn't work ?


Re: regsub vartext backreferences followed by digits #39566 05/08/03 12:17 AM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Well for one thing because technically PCRE can capture up to 65535 matches. Plus it would just generally be bad syntax (IMO) to behave like that in that situation.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: regsub vartext backreferences followed by digits #39567 05/08/03 12:58 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
but that's the only way
replacing it with other character is a bad idea

Re: regsub vartext backreferences followed by digits #39568 05/08/03 01:09 AM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
That part is parsed by the PCRE engine anyway, so it's not like mIRC can really do much about that.


Spelling mistakes, grammatical errors, and stupid comments are intentional.