This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.



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 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(value, delim)
value String: the String to be split
delim char: the character or String used to separate the data
Updated on July 4, 2018 11:56:43am EDT

Creative Commons License