mIRC Homepage
Posted By: KyD regsub vartext backreferences followed by digits - 04/08/03 02:43 AM
$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?
oops double thread, we had a misunderstanding in who was to post the question here on the forum.
sorry about this.
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.
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.
Err indeed, you're right, no idea why I said 255, I meant 127
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.
if \999 is the maximum matches so why \1\9992 doesn't work ?

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.
but that's the only way
replacing it with other character is a bad idea
That part is parsed by the PCRE engine anyway, so it's not like mIRC can really do much about that.
© mIRC Discussion Forums