mIRC Homepage
Posted By: Ghozer help with hash table and regex - 25/09/07 10:45 PM
im attempting to delete all items NOT matching *.*

for example, items such as

nick -> user
this -> that

would be deleted, and items such as

nick.them -> user
this.something -> that

would NOT be deleted... Im using the code below...

Code:
alias del_users {
 var %x = 1
 while (%x <= $hfind(nicks,/^?!((.+?)\.(.+?)))/,0,r)) {
   hdel nicks $hfind(nicks,/^?!((.+?)\.(.+?)))/,%x,r)
   inc %x
 }
}


The trouble is.. if there's 3 entries, it only deletes the first 2... if there's 6 it only deletes the first 5....

i have tried it with var %x = 0 and also tried it as < instead of <= in the while...

any ideas???
Posted By: RusselB Re: help with hash table and regex - 25/09/07 11:00 PM
The problem is that you're deleting an item and increasing %x.

Try this instead
Code:
alias del_users {
 var %x = 1
 while (%x <= $hfind(nicks,/^?!((.+?)\.(.+?)))/,0,r)) {
   hdel nicks $hfind(nicks,/^?!((.+?)\.(.+?)))/,%x,r)
   dec %x
 }
 inc %x
}

Posted By: Ghozer Re: help with hash table and regex - 25/09/07 11:13 PM
That just freezes mIRC...

* Break: command halted (line 278, core.aow)

line 278 = while (%x <= $hfind(nicks,/^?!((.+?)\.(.+?)))/,0,r)) {
Posted By: deegee Re: help with hash table and regex - 25/09/07 11:16 PM
When you delete the 1st matching item, what was the 2nd is now the 1st, so you just need to keep deleting the 1st match wink
Code:
alias del_users {
  while ($hfind(nicks,/^[^.]+$/,1,r)) { hdel nicks $v1 }
}
Posted By: Ghozer Re: help with hash table and regex - 25/09/07 11:23 PM
ty deegee - i thought something similar, but using my longer regex wink

works perfect that wink n1
© mIRC Discussion Forums