Definition: | sequence res = split_any(sequence source, object delimiters=", \t|", bool no_empty=false, integer limit=0) |
Description: |
Split a sequence on any of the specified delimiters into a number of sub-sequences.
Returns a sequence, of sub-sequences of source. All instances of any of the specified delimiters are removed. |
Comments: |
This function may be applied to a string or a complex sequence.
if delimiters is an atom this function behaves identically to split(). (For this routine to behave identically to split() with a non-atom delimiter, you need to pass a length-1 sequence with that non-atom value as the only element, to this routine.) If no_empty is false, any zero-length sub-sequences are not added to the result sequence. Use this when leading, trailing, and duplicated delimiters are not significant. If limit is greater than 0, it specifies the maximum number of sub-sequences that will be created, otherwise there is no limit. The use of named parameters is advised when setting no_empty and/or limit. |
Example: |
s = split_any("{one,two,three}","{,}",no_empty:=true) -- s is {"one","two","three"} The use of a named parameter for no_empty makes the intent much clearer. |
See Also: | join, flatten, columnize, split |