Positive Lookbehind Regular Expression to split a string while preserving the separators in the sub-strings:
split(/(?<=[<separator characters go here>])/)
What is Lookbehind? §
Lookbehind in regular-expression allows to match a pattern only when it follows the given lookbehind pattern (without actually matching it).
- Positive lookbehind:
(?<=Y)Xmatches X if there is Y before it.
- Negative lookbehind:
(?<!Y)Xmatches X if there is no Y before it.