mIRC Home    About    Download    Register    News    Help

Topic Options
#39559 - 04/08/03 03:43 AM regsub vartext backreferences followed by digits
KyD Offline
Pikka bird

Registered: 23/12/02
Posts: 17
Loc: the netherlands
$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?

Top
#39560 - 04/08/03 03:51 AM Re: regsub vartext backreferences followed by digits
KyD Offline
Pikka bird

Registered: 23/12/02
Posts: 17
Loc: the netherlands
oops double thread, we had a misunderstanding in who was to post the question here on the forum.
sorry about this.

Top
#39561 - 04/08/03 04:05 AM Re: regsub vartext backreferences followed by digits
codemastr Offline
Hoopy frood

Registered: 12/12/02
Posts: 2809
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.

Top
#39562 - 04/08/03 10:52 PM Re: regsub vartext backreferences followed by digits
lammkott Offline
Fjord artisan

Registered: 12/05/03
Posts: 215
Loc: Australia
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

Top
#39563 - 04/08/03 10:56 PM Re: regsub vartext backreferences followed by digits
codemastr Offline
Hoopy frood

Registered: 12/12/02
Posts: 2809
Err indeed, you're right, no idea why I said 255, I meant 127

Top
#39564 - 04/08/03 10:56 PM Re: regsub vartext backreferences followed by digits
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
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

Top
#39565 - 05/08/03 12:54 AM Re: regsub vartext backreferences followed by digits
ScatMan Offline
Hoopy frood

Registered: 06/05/03
Posts: 730
if \999 is the maximum matches so why \1\9992 doesn't work ?


Top
#39566 - 05/08/03 01:17 AM Re: regsub vartext backreferences followed by digits
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
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.

Top
#39567 - 05/08/03 01:58 AM Re: regsub vartext backreferences followed by digits
ScatMan Offline
Hoopy frood

Registered: 06/05/03
Posts: 730
but that's the only way
replacing it with other character is a bad idea

Top
#39568 - 05/08/03 02:09 AM Re: regsub vartext backreferences followed by digits
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
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.

Top