07:43What do ya all think about generalizing
split?
split: func [
{Break series into pieces using the provided delimiter(s)}
series [series!] "Series to break up"
dlm [char! string! bitset! block!] "Delimiter (block! is parse rule)"
/local _
][
parse/case series [
collect any [
keep copy _ [to [dlm | end]]
opt dlm
]
]
]>> split "abcdef" #"c"
== ["ab" "def"]
>> split "abcdef" "cd"
== ["ab" "ef"]
>> split "abcdef" charset "cd"
== ["ab" "def"]
>> split [a b c d e f] ['c]
== [[a b] [d e f]]
>> split [a b c d e f] ['c 'd]
== [[a b] [e f]]
>> split [a b c d e f] ['c | 'd]
== [[a b] [d e f]]
>> split [1 2 3 4 5] [quote 3]
== [[1 2] [4 5]]
>> split [a b 3 cd] [number!]
== [[a b] [cd]]
>> split [a = b + c] ['=]
== [[a] [b + c]]