There are 4 token identifiers used when searching for a token. Each has a different use, depending on what information you need returned. $findtok gives a token position, $matchtok and $wildtok return the tokens themselves, and $istok returns $true or $false if the substring is/isn't a token.
$findtok is used to find the
Nth position number of a known complete token:
- $findtok(pencil crayon stylus pen chalk, pen, 1, 32) returns 4 since pen is the fourth space-delimited token.
$matchtok is used if you only know an exact substring portion of a token to return the Nth
token itself:
- $matchtok(pencil crayon stylus pen chalk, pen, 1, 32) returns pencil since it is the first token that has "pen" in it.
$matchtok(pencil crayon stylus pen chalk, pen, 2, 32) returns pen since it is the second token that has "pen" in it.
$wildtok is used like $matchtext, except you can use ? (single character) and * (0 or more characters) for the parts you don't know:
- $wildtok(pencil crayon stylus pen chalk, p?n*, 1, 32) returns pencil ("e" matches ? and "cil" matches *)
$wildtok(pencil crayon stylus pen chalk, p?n*, 2, 32) returns pen ("e" matches ? and "" matches *)
$istok is used if you only want to know
if the token exists (in its complete form):
- $istok(pencil crayon stylus pen chalk, pen, 32) returns $true (it's the fourth token)
As with most identifiers of this sort, you can use
$*tok(string, substring, 0, 32) to return the number of matches found in the entire string, where $*tok is $findtok, $matchtok or $wildtok.
NOTE: There are case-sensitive versions of each:
$findtokcs(),
$matchtokcs(),
$wildtokcs() and
$istokcs().