3.5.5.25 Token

Description

Get the Nth token from a string using specified delimiter.

Syntax

string Token(string str$, int iToken [, int iDelimiter =0])$

Parameters

str

The string from which you want to get token.

iToken

Specifies the token index. (from 1)

iDelimiter

Indicates the ASCII value of the delimiter. The default 0 denotes any white space characters. 32 means single space and 124 means '|'. You can also directly use char type such as '_' (ASCII 95), '|'(ASCII 124) as the value of iDelimiter which is equivalent to its corresponding ASCII value.

Note: some symbol chars might not be directly used by iDelimiter but their ASCII values always apply.

Return

returns Nth token in the string.

Example

str1$="This is my string";
str2$=Token(str1$,3)$;
str2$=;//should be "my"
str1$="This\is\my\string";
str2$=Token(str1$, 2, '\')$;
str2$=;//should be "is"
str1$="This#is#my#string";
int ascval = code("#"); //ascval is 35
str2$=Token(str1$, 4, $(ascval))$;
str2$=;//should be "string"

See Also

Mid