references/sleep-functions/split.md

GitHub

split

Category: Strings

Source: https://sleep.dashnine.org/manual/split.html


Synopsis

@ split('pattern', "string", [limit])

splits the specified string by the specified pattern

Parameters

"string" - the string to split

'pattern' - the pattern that defines substrings this string should be broken up by.

    1. Regular Epxressions - tutorial on regular expression language

limit - limits the number of segments to split the sentence into.

Returns

a scalar array

Examples

Example:

@data = @("Raphael,Professional Escort,NY",
"Frances,Sales Warrior,MI");

foreach $var (@data)
{
($name, $job, $state) = split(',', $var);
println("$name works as a $job in $state");
}

Output:

Raphael works as a Professional Escort in NY
Frances works as a Sales Warrior in MI

See Also

&find; hasmatch; ismatch; &join; &matched; &matches; &replace