This question already has an answer here:
I'm splitting a string by three different characters but I want the output to include the characters I split by. Is there any easy way to do this?
This question already has an answer here:
I'm splitting a string by three different characters but I want the output to include the characters I split by. Is there any easy way to do this?
Recently I wrote an extension method do to this:
(EDIT - this is a bad answer - I misread his question and didn't see that he was splitting by multiple characters.)
(EDIT - a correct LINQ version is awkward, since the separator shouldn't get concatenated onto the final string in the split array.)
This seems to work, but its not been tested much.
Regex.Split looks like it might be able to do what you want perhaps.
Java code:
Output: