I have the following example string:
A|B\|C\\|D\\\|E\\\\F
with | being the delimiter and \ being the escape character. A proper split should look as follows:
A
B\|C\\
D\\\|E\\\\
F
Also I need this logic to be generally applicable in case the delimiter or the escape consists out of multiple characters.
I already have a regex which splits at the correct position, but it does not produce the desired output:
Regex:
(?<!\Q\\E)(?:(\Q\\\E)*)\Q|\E
Output:
A
B\|C
D\\\|E
F
I am usually testing here: https://regex101.com/, but am working in java so I have a little more capabilities.
Also tried the following with no positive result as well (doesn't work on the webpage, but in java just doesn't produce the desired result):
(?=(\Q\\\E){0,5})(?<!\Q\\E)\Q|\E