Name |
splitTokens()分隔符令牌 |
||||
Examples |
String t = “a b”; String[] q = splitTokens(t); println(q[0]); // Prints “a” println(q[1]); // Prints “b”
// Despite the bad formatting, the data is parsed correctly. // The “, ” as delimiter means to break whenever a comma *or* // a space is found in the String. Unlike the split() function, // multiple adjacent delimiters are treated as a single break. String s = “a, b c ,,d “; String[] q = splitTokens(s, “, “); println(q.length + ” values found”); // Prints “4 values found” println(q[0]); // Prints “a” println(q[1]); // Prints “b” println(q[2]); // Prints “c” println(q[3]); // Prints “d” |
||||
Description |
The splitTokens() function splits a String at one or many character delimiters or “tokens.” The delim parameter specifies the character or characters to be used as a boundary. If no delim characters are specified, any whitespace character is used to split. Whitespace characters include tab (\t), line feed (\n), carriage return (\r), form feed (\f), and space. After using this function to parse incoming data, it is common to convert the data from Strings to integers or floats by using the datatype conversion functions int() and float(). splitTokens () 函数将字符串拆分为一个或多个字符分隔符或 “令牌“。delim 参数指定要用作边界的字符或字符。
如果未指定 delim 字符, 则使用任何空白字符进行拆分。空白字符包括制表符 (\t)、行提要 (\n)、回车符 (\r)、窗体提要 (\n) 和空格。
使用此函数分析传入数据后, 通常可以使用数据类型转换函数 int () 和 float () 将字符串转换为整数或浮点数。 |
||||
Syntax |
splitTokens(value) splitTokens(value, delim) |
||||
Parameters |
|
||||
Returns |
String[] |
||||
Related |
split() |
- 本文固定链接: http://iprocessing.cn/2017/07/21/splittokens分隔符令牌/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表