I tried to add this as a comment to the request without the knowledge, but I donβt know how to format it there ...
In any case, the answer to my eyelids seems correct:
String str = "aaa|bbbb|cccc|dddd\\|eeee|ffff"; String[] tokens = str.split("(?<!\\\\)\\|"); System.out.println(Arrays.toString(tokens));
which prints:
[aaa, bbbb, cccc, dddd\|eeee, ffff]
source share