mIRC Home    About    Download    Register    News    Help

Print Thread
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?

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.

Joined: Dec 2002
Posts: 2,809
C
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.

Joined: May 2003
Posts: 215
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
Joined: Dec 2002
Posts: 2,809
C
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

Joined: Jan 2003
Posts: 2,523
Q
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
Joined: May 2003
Posts: 730
S
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
if \999 is the maximum matches so why \1\9992 doesn't work ?


Joined: Dec 2002
Posts: 2,962
S
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.
Joined: May 2003
Posts: 730
S
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

Joined: Dec 2002
Posts: 2,962
S
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.

Link Copied to Clipboard