Name |
split()分隔符 |
||||
Examples |
String men = “Chernenko,Andropov,Brezhnev”; String[] list = split(men, ‘,’); // list[0] is now “Chernenko”, list[1] is “Andropov”…
String numbers = “8 67 5 309”; int[] nums = int(split(numbers, ‘ ‘)); // nums[0] is now 8, nums[1] is now 67…
String men = “Chernenko ] Andropov ] Brezhnev”; String[] list = split(men, ” ] “); // list[0] is now “Chernenko”, list[1] is “Andropov”… |
||||
Description |
The split() function breaks a String into pieces using a character or string as the delimiter. The delim parameter specifies the character or characters that mark the boundaries between each piece. A String[] array is returned that contains each of the pieces. If the result is a set of numbers, you can convert the String[] array to to a float[] or int[] array using the datatype conversion functions int() and float(). (See the second example above.) The splitTokens() function works in a similar fashion, except that it splits using a range of characters instead of a specific character or sequence. split () 函数使用一个字符或字符串作为分隔符将字符串分成几部分。delim 参数指定标记每个棋子之间边界的字符或字符。返回一个包含每个片断的字符串 [] 数组。
如果结果是一组数字, 则可以使用数据类型转换函数 int () 和 float () 将字符串 [] 数组转换为浮点型 [] 或 int [] 数组。(请参见上面的第二个示例。
splitTokens () 函数的工作方式类似, 只不过它使用一系列字符而不是特定的字符或序列进行拆分。 |
||||
Syntax |
split(value, delim) |
||||
Parameters |
|
||||
Returns |
String[] |
- 本文固定链接: http://iprocessing.cn/2017/07/21/split分隔符/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表