Difference between revisions of "$wildtok"

From Scriptwiki
Jump to: navigation, search
m (re-word)
m (Example)
Line 14: Line 14:
 
  }
 
  }
 
This example would at first echo the number of matches, so ''2'', as an ''o'' is in ''cow'' and ''dog'', then echo these tokens using a while loop.
 
This example would at first echo the number of matches, so ''2'', as an ''o'' is in ''cow'' and ''dog'', then echo these tokens using a while loop.
 +
  
 
This is an example to check if a channel name has been side in a varible or string, useful for anti-advertising scripts.
 
This is an example to check if a channel name has been side in a varible or string, useful for anti-advertising scripts.

Revision as of 15:16, 3 July 2006

Returns the Nth token that matches the wildcard string.

$wildtok(tokens,wildstring,N,C)

Note that if you specify zero for N, it returns the total number of matching tokens.

Example

var %mytext = fish cow cat dog sheep
var %number_of_matches = $wildtok(%mytext,*o*,0,32)
echo -a %number_of_matches
var %i = 1
while (%i <= %number_of_matches) {
   echo -a $wildtok(%mytext, *o*, %i ,32) 
   inc %i
}

This example would at first echo the number of matches, so 2, as an o is in cow and dog, then echo these tokens using a while loop.


This is an example to check if a channel name has been side in a varible or string, useful for anti-advertising scripts.

on *:text:*#*:#: { 
  if ($wildtok($1-,#?*,0,32) >= 1) echo -ag You're advertising $nick and thats not allowed!
}