mIRC Home    About    Download    Register    News    Help

Print Thread
Is this a bug #94357 15/08/04 07:44 PM
Joined: Feb 2003
Posts: 282
S
saragani Offline OP
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
I'm building a spam blocker which has lots f experssions it can get (so instead of using lots of elseif statemens I use a hash table with regular expressions because I want some of the data inside the spam to be returned).

For example:

ITEM Data
1 ----- (?i)It seems that you have been infected with (.*) please download a cleaner for this virus
2 ----- (?i)HI! My name is (.*) I need boyfriend


Now I use:
on *:NOTICE:*:?: {
if ($hfind(spam,$1-,1,R).data > 0) {
echo 4 -a $v1 $regml(1)
}
}
(Its for testing. In real life it gets provate messages and not notices).

I would assume that when it finds the first item I told it to find, it would halt and return, so I could regrieve the $regml(1), but infact, with all the 60 (or more) spam messages that I have, I can get the $regnl(1) from only one spam message... I'm guessing that it is the last message inside the hash table (When it is not the last one then the search continues and the $regml(1) is being erased).


Wouldn't it be logical to return to the script as soon as it should the first result so the $regml will not be deleted? confused
(Otherwise, what a good reason would I have to use regual expressions ??? confused, I could just use wild card. I know that not all expressions can be written in wildcard form).

Thanks wink


//EDIT:
Btw, would anyone suggest a way to get the $regml anyway or using another fast method (and not elseif statements which can be slow when dealing with lots of expressions, and while assumeing the worst case scenario that the expresion I'm looking for is the last one in the elseif statements).


Last edited by saragani; 15/08/04 07:46 PM.
Re: Is this a bug #94358 15/08/04 09:36 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
$hfind seems to search the complete hash table in $hget(hash,n).item sequence, so the $regml you get is the one for item $hget(hash,$hget(hash,0).item).item.

I agree it would be more logical that matching would stop at the point where the requested match has been found...


For your problem now: if (($hfind(spam,$1-,1,R).data) && ($regex($1-,$hget(spam,$v1)))) { ... }

Re: Is this a bug #94359 16/08/04 07:11 AM
Joined: Feb 2003
Posts: 282
S
saragani Offline OP
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
Thanks, I thought about a similar solution for the problem too (I mean returning the $hget(spam,$v1) regex expression to the $regex for extracting the $regml information.


Thank you for your help.