Search processing.org:

Reference for Processing (BETA) version 0135+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Name | ### split()
Examples |
    String men = "Chernenko,Andropov,Brezhnev";
    String list[] = split(men, ',');
    // list[0] is now Chernenko, list[1] is Andropov, ...
    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, ...
Description | The split() function is used to divide a String into its separate elements. This function splits a string into pieces using a character or string as the divider. The delim parameter specifies the character or characters which mark the boundaries between each data element. To convert a String to an array of integers or floats, use the datatype conversion functions int() and float() to convert the array of Strings (see example above).
Syntax |
    split(str, delim)
Parameters |
str | the String to be split
delim | the character or String used to separate the data
Usage | Web & Application
Related | splitTokens() join() trim()

Updated on May 24, 2007 06:36:43pm PDT