Splits the source string into a list of all substrings between each instance of the separator.
The separator itself is excluded from the substrings. In the case of overlapping instances of the separator, the leftmost match is considered.
Empty substrings are included in the list.
If the separator is not found, then a list containing only the source string is returned.
Arguments
Arguments | |
---|---|
source |
The string that will be split. |
separator |
The separator used to split the string. |
Returns
A list of substrings in source
.
Raised exceptions
Exceptions | |
---|---|
TypeError |
If either source or separator is not a string. |
ValueError |
If separator is an empty string or is not UTF-8 encoded. |
Examples
Example 1
# Overlapping separator instances; leftmost match is considered - returnStep: return: ${text.split("baaab", "aa")} # returns `["b", "ab"]`
Example 2
# Separator is found at beginning of string - returnStep: return: ${text.split("abc", "a")} # returns `["", "bc"]`
Example 3
# Separator is found at end of string - returnStep: return: ${text.split("abc", "c")} # returns `["ab", ""]`
Example 4
# Consecutive instances of the separator - returnStep: return: ${text.split("abbc", "b")} # returns `["a", "", "c"]`