Let's say we have a string:
String x = "a| b |c& d^ e|f";
What I want to obtain looks like this:
a
|
b
|
c
&
d
^
e
|
f
How can I achieve this by using x.split(regex)
? Namely what is the regex?
I tried this link: How to split a string, but also keep the delimiters?
It gives a very good explanation on how to do it with one delimiter. However, using and modifying that to fit multiple delimiters (lookahead and lookbehind mechanism) is not that obvious to someone who is not familiar with regex.