There is a clever 1st answer given here for splitting swift string with a regex expression
However it keeps the searched text within the array of answers. I'm trying to do a similar thing, but ignoring the characters acting as separators (e.g. just like the swift split function, but just with a regex expression as the separator).
As an example: regex would be something like
"\\\||Z|ZY"
and when applied to string of "hi|thisZshouldZYbe|separated"
then you would get back an array
["hi", "this", "should", "be", "separated"]
NB. The regex is adapted to the swift NSRegularExpression format with the double escape. In regular regex it would just be "\||Z|ZY" Also NB the regex contains the vertical line symbol not the letter "l"
You prob don't need to do too many tweaks to the original to make work.