mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2004
Posts: 16
C
Pikka bird
OP Offline
Pikka bird
C
Joined: Nov 2004
Posts: 16
hi, i'am making small improved highlight system ( i can define, whitch words have to be in text, whitch may be and whitch cant be)

if ( (good1 isin $1-) || (good2 isin $1-) || (good3 isin $1-) ...... ) { ... }
or
if ( (bad1 !isin $1-) && (bad2 !isin $1-) && (bad3 !isin $1-) ...... ) { ... }

and this is, what i want. have all these word together
forexample:
var %goodwords = good1, good2, good3, ...
var %badwords = bad1, bad2, bad3, ...

and then i can use only %goodwords and %badwords in condition?

can anyone help with this easy(i hope) idea?

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Assuming the words in %goodwords and %badwords contain only alphanumeric characters (a-z and 0-9), you can use something like this:
Code:
if $regex($1-,$+(/,$replace([color:red]%goodwords[/color],$chr(32),,$chr(44),|),/iS)) { ... }


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Nov 2004
Posts: 16
C
Pikka bird
OP Offline
Pikka bird
C
Joined: Nov 2004
Posts: 16
Thanks, that is exactly what i want. can you help me for example with %badwords? all of them have to be in $1- to execute script (in my first example i show && between them )

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
alias goodwords return $regex($1,$+(/,$replace(%goodwords,$chr(32),,$chr(44),|),/Si))
alias badwords return $regex($1,$+(/,$replace(%badwords,$chr(32),,$chr(44),|),/Si))

if $goodwords($1-) { ... } --> will trigger if one of the good words is in $1-
if !$badwords($1-) { ... } --> will trigger if none of the bad words are in $1-

I must say, that I think a hash table and $hfind will be more appropriate for this kind of thing. Why? The regex will get slower when your %goodwords and %badwords start getting big, and in a hash table, you can add many more items than you can in a variable.

Greets

Joined: Nov 2004
Posts: 16
C
Pikka bird
OP Offline
Pikka bird
C
Joined: Nov 2004
Posts: 16
thx, iam going to search in forums and /help and try something code. hope i find out how this works smile


Link Copied to Clipboard