command (MEL) | Only available inMEL |
tokenize | In categories: Language, Strings |
No Frames
Go to: Synopsis. Return value. MEL examples.
Synopsis
tokenize string [string] string[]
tokenize is NOT undoable, NOT queryable, andNOT editable.
This command will split the first string argument up accordingto split characters provided in the optional second argument. Ifthis argument is not provided, tokenize will use a default splitstring consisting of whitespace characters. The input string isscanned for substrings (tokens) which are separated by any of thesplit characters. Note: tokenize does not match the entire splitstring; it matches any character in the string. The resulting tokenstrings are put into the third argument which is a string array.The return value of this procedure is the number of tokens intowhich the original string is divided.
这个命令根据第二个字符串做参考将第一个字符串进行分割。如果没有提供第二个参考字符串,系统将默认用空格分割第一个字符串。
注:分割的依据并非第二个字符串整体,而是第二个字符串中的任意字符。
由此产生的分割好的字符串存储在第三个字符串数组中。在此过程中的返回值是一个整数值,为分割了多少个字符串。
Return value
int | Number of tokens |
MEL examples
string $buffer[];
$numTokens = `tokenize "A/B//C/D" "//" $buffer`;
// Buffer will contain 4 strings, not 2: "A", "B", "C", "D"
字符串将被分割为四个字符串(不是两个),分别为:"A", "B", "C", "D"
// and $numTokens will be 4.
返回值为4
string $buffer[];
$numTokens = tokenize("Mildred Pierce Femme Fatale", $buffer);
// Buffer will contain 4 strings: "Mildred", "Pierce", "Femme", and "Fatale."
字符串将被分割为四个字符串,分别为:"Mildred", "Pierce", "Femme", 和 "Fatale"
// and $numTokens will be 4.
返回值为4
string $buffer[];
$numTokens = `tokenize "testing=non-default separators" "=" $buffer`;
// Buffer will contain 2 strings: "testing" and "non-default separators."
字符串将被分割为两个字符串,分别为:"testing" 和 "non-default separators"
// and $numTokens will be 2.
返回值为2