Difference between revisions of "$wildtok"

From Scriptwiki
Jump to: navigation, search
(Small update for info about channel matching.)
m (side->said)
 
(2 intermediate revisions by the same user not shown)
Line 15: Line 15:
 
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.
  
An other example is 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 said in a varible or string, useful for anti-advertising scripts.
 
  on *:text:*#*:#: {  
 
  on *:text:*#*:#: {  
 
   if ($wildtok($1-,#?*,0,32) >= 1) echo -ag You're advertising $nick and thats not allowed!
 
   if ($wildtok($1-,#?*,0,32) >= 1) echo -ag You're advertising $nick and thats not allowed!

Latest revision as of 16:17, 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 said 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!
}