Find n-th token (part, word) of string

Syntax

int findt(string [n] [delim] [flags])

 

Parameters

string - string to search in.

n - 0-based index of token. Default: -1.

delim - delimiters.

flags:

0x100 delim is table of delimiters.
0x200 QM 2.3.3. Add blanks to delim.

 

Remarks

Returns 0-based index of first character of n-th token (substring delimited by characters in delim) in string. If there are less than n+1 tokens, returns -1.

 

If n is omitted or negative, finds next token. It works in same function only.

 

Tips

To find lines, use findl.

 

See also: gett findrx

 

Examples

 find the second token
str s = "my.exe /cl"
int i = findt(s 1 " .:\/''[]")
out i ;;3

 for each word
int t
for t 0 1000000000
	i=findt(s -t)
	if(i<0) break
	out i