Difference between revisions of "$wildtok"

From Scriptwiki
Jump to: navigation, search
(No difference)

Revision as of 23:06, 15 November 2005

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.