Name
String.split() — break a string into an array of strings
Synopsis
string.split(delimiter,limit)
Arguments
delimiterThe string or regular expression at which the
stringsplits.limitThis optional integer specifies the maximum length of the returned array. If specified, no more than this number of substrings will be returned. If not specified, the entire string will be split, regardless of its length.
Returns
An array of strings, created by splitting
string into substrings at the
boundaries specified by delimiter. The
substrings in the returned array do not include
delimiter itself, except in the case
noted in the Description.
Description
The split() method creates
and returns an array of as many as limit
substrings of the specified string. These substrings are created by
searching the string from start to end for text that matches
delimiter and breaking the string before
and after that matching text. The delimiting text is not included in
any of the returned substrings, except as noted at the end of this
section. Note that if the delimiter matches the beginning of the
string, the first element of the returned array will be an empty
string—the text that appears before the delimiter. Similarly, if the
delimiter matches the end of the string, the last element of the
array (assuming no conflicting limit)
will be the empty string.
If no delimiter is specified, the
string is not split at all, and the returned array contains only a
single, unbroken string element. If
delimiter is the empty ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access