Split on the given sublist. Equivalent to split
. dropDelims . onSublist.
splitOn ":" "12:35:07"["12","35","07"]
splitOn "x" "axbxc"["a","b","c"]
splitOn "x" "axbxcx"["a","b","c",""]
splitOn ".." "a..b...c....d.."["a","b",".c","","d",""]
In some parsing combinator frameworks this is also known as
sepBy.
Note that this is the right inverse of the intercalate function from Data.List, that is,
intercalate x . splitOn x === id
splitOn x . intercalate x is the identity on
certain lists, but it is tricky to state the precise conditions
under which this holds. (For example, it is not enough to say
that x does not occur in any elements of the input list.
Working out why is left as an exercise for the reader.)