mIRC Home    About    Download    Register    News    Help

Print Thread
help with hash table and regex #186752 25/09/07 10:45 PM
Joined: Oct 2006
Posts: 48
G
Ghozer Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2006
Posts: 48
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???

Re: help with hash table and regex [Re: Ghozer] #186753 25/09/07 11:00 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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
}


Re: help with hash table and regex [Re: RusselB] #186754 25/09/07 11:13 PM
Joined: Oct 2006
Posts: 48
G
Ghozer Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2006
Posts: 48
That just freezes mIRC...

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

line 278 = while (%x <= $hfind(nicks,/^?!((.+?)\.(.+?)))/,0,r)) {

Re: help with hash table and regex [Re: Ghozer] #186755 25/09/07 11:16 PM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
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 }
}

Re: help with hash table and regex [Re: deegee] #186756 25/09/07 11:23 PM
Joined: Oct 2006
Posts: 48
G
Ghozer Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2006
Posts: 48
ty deegee - i thought something similar, but using my longer regex wink

works perfect that wink n1