Aller au contenu principal

explode

Split a string by string

EXPLODE

NAME

explode - Splits a string by string

SYNOPSIS

(delimiter,string,limit)

DESCRIPTION

Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string separator.

PARAMETERS

delimiter
The boundary string.
string
The input string.
limit
If the limit is set and is positive, the returned array will contain a maximum of limit elements with the last element containing the rest of string. If the limit parameter is negative, all components except the last -limit are returned. If the limit parameter is zero, then this is treated as being 1.

RETURN

Returns an array of strings created by splitting the string parameter on boundaries formed by the delimiter.

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

in:  res={_{explode("","test t2 t3");}}.
out: res=["t","e","s","t"," ","t","2"," ","t","3"].

in:  res={_{explode("","test t2 t3",-2);}}.
out: res=["t","e","s","t"," ","t","2"," "].

in:  res={_{explode("","test t2 t3",2);}}.
out: res=["t","est t2 t3"].

in:  res={_{explode(",","a,b,c");}}.
out: res=["a","b","c"].

in:  res={_{explode("t","ttest t2 t3t");}}.
out: res=["","","es"," ","2 ","3",""].

in:  res={_{explode("test","ttest test2 t3t");}}.
out: res=["t"," ","2 t3t"].

SEE ALSO

{{ include("includes/strings.sn") }}

AUTHOR

Written by Pusnei Sergey and Caroline Laplante, <sergey@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.