a port of the Processing Visualization Language
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 divider. 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 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.

Syntax
split(str,delim)
Parameters
str the String to be split
delim the character or String used to separate the data
Returns String[]
Usage Web & Application
Related splitToken()
trim()
join()

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub