STRING::EXPLODE 1g 2023-09-11 laplante@plcb.ca GOWEB — Split Strings into Substrings


title: “STRING::EXPLODE” version: “1.0.0” date: 2023-09-11 author: “laplante@plcb.ca” section: “1g”

category: “GOWEB”

Name

string::explode Split Strings into Substrings

Synopsis

string::explode(string [, delimiter, limit])
explode(string [, delimiter, limit])

Description

The explode function splits a string into a list of substrings based on a given delimiter.

If no delimiter is specified, the string is split into individual characters.

The behavior depends on the limit parameter:

An alternate function name, splitN, is also available.


Parameters


Examples

res={{
    explode("514-345-7890", "-"); "\n";
    explode("514-345-7890", "-", 2); "\n";
    explode("A||B||C", "||"); "\n";
    explode("test t2 t3", ""); "\n";
    explode("test t2 t3", "", 2); "\n";
    explode("ttest t2 t3t", "t"); "\n";
    explode("ttest test2 t3t", "test"); "\n";
    explode(789, "");
}};

Returns:

res = ["514","345","7890"]
["514","345-7890"]
["A","B","C"]
["t","e","s","t"," ","t","2"," ","t","3"]
["t","est t2 t3"]
["","","es"," ","2 ","3",""]
["t"," ","2 t3t"]
["7","8","9"]

Author


See Also


Version History