splitTokens() \ Language (API) \ Processing 1.0
Author: Casey Reas & Ben Fry
Description: Processing is an electronic sketchbook for developing ideas. It is a context for learning fundamentals of computer programming within the context of the electronic arts.
Keywords: Processing, Processing, Interactive Media, Electronic Arts, Programming, Java, Ben Fry, Casey Reas

Reference for Processing version 1.5. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

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[] p = splitTokens(s, ", ");
    println(p[0]); // Prints "a"
    println(p[1]); // Prints "b"
    println(p[2]); // Prints "c"
    println(p[3]); // Prints "d"
Description | The splitTokens() function splits a String at one or many character "tokens." The tokens parameter specifies the character or characters to be used as a boundary. If no tokens character is specified, any whitespace character is used to split. Whitespace characters include tab (\t), line feed (\n), carriage return (\r), form feed (\f), and space. 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.
Syntax |
    splitTokens(str)
    splitTokens(str, tokens)
Parameters |
str | the string to be split
tokens | list of individual characters that will be used as separators
Returns | String[]
Usage | Web & Application
Related | split() join() trim()

Updated on August 30, 2010 04:29:39pm EDT