mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2004
Posts: 81
N
Babel fish
OP Offline
Babel fish
N
Joined: Dec 2004
Posts: 81
I've written an alis to do this already just wondering if it's possible to do this using regex? I've tried the following but it only strips one occurrence:

Code:
//var %reg = (\w+\b)\s | echo -a $regsub(test blah test this is a test,%reg,$chr(32),%var) | echo -a %var


Output

blah test this is a test

Joined: Jun 2005
Posts: 11
H
Pikka bird
Offline
Pikka bird
H
Joined: Jun 2005
Posts: 11
Remove occurences of what? smile


- hantu
Joined: Dec 2004
Posts: 81
N
Babel fish
OP Offline
Babel fish
N
Joined: Dec 2004
Posts: 81
Words. Words appearing more than once in a string.

Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
use the /g option so it replaces all the matches in the string


$maybe
Joined: Jul 2003
Posts: 655
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
Indeed, and grep's should always be surrounded by //'s in mirc scripting

var %reg = /(\w+\b)\s/g


"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
This alias removes words closer to the beginning of the string if they already exist as words further on:

Code:
remrpts var %i | return $(,,$regsub($1,/(?:^| )([^ ]+)(?= )(?=.* \1(?: |$))/gs,,%i)) %i

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Nice usage of $eval, I'll remember that one. Much preferable over $null which can be overriden by a scripted version, unlike $()


Gone.
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Nice indeed smile Shorter and a tiny bit faster than !.echo -q (although the difference is really really small, almost immeasurable. The identifier call overhead seems to almost match up with the one of the extra command). Definitely gonna use it.

$() is weird, you can find other little oddities if you play with it. So far the only one I'm probably going to use is $(,stuff) which is the same as $(stuff,2) , only a tiny bit faster. Oh and I believe you know about $(stuff,) already (which is the same as $(stuff,0)).


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:
So far the only one I'm probably going to use is $(,stuff) which is the same as $(stuff,2) , only a tiny bit faster. Oh and I believe you know about $(stuff,) already (which is the same as $(stuff,0)).

I didn't know about $(,stuff) being $(stuff,2)

Yes, I've used the $(stuff,) one heavily when passing code to scon, although nowadays, I try to steer away from passing code to scon in that way. Too many people, who are unaware of the dangers etc. copy the code, modify it, and then come back complaining that it doesn't work :tongue:

Btw I would reckon multiple identifiers have this sort of behaviour as what Sigh_ did, check out:

//echo -a $time(,$regex(b,(.))) $regml(1)

Another thing I only found out recently is that if you have a scripted version for an identifer like:

alias me return lol

You can make it return the scripted version by putting $me(), instead of doing $.me or $/me etc
But I'm guessing you already knew that anyway :tongue:

Last edited by FiberOPtics; 18/10/05 01:36 PM.

Link Copied to Clipboard