split
splits a string using a separator
(string subject, string separator, boolean isRegex, long limit) -> list
Splits a string using a separator. The parts of the string are returned as a list of strings.
Parameters
Name |
Type |
Description |
subject |
string |
The string to split |
separator |
string |
The separator to use |
isRegex |
boolean |
If true , separator is interpreted as a regular expression. |
limit |
long |
The limit setting controls how many parts to produce, and how to handle trailing empty strings:
-
If limit == 0 then the separator will be applied as many times as possible, the resulting parts list can have any length, and trailing empty strings are discarded.
-
If limit > 0 then the separator is applied at most limit times.
The resulting parts list’s length is no greater than the given limit, and the list’s last entry will contain
all characters beyond the last matched separator.
-
If limit < 0 or if limit is nil then the separator will be applied as many times as possible and the resulting parts list can have any length. Traling empty strings are preserved.
|