I have searched the web for my query, but didn't get the answer which fits my requirement exactly. I have my string like below:
A|B|C|The Steading\|Keir Allan\|Braco|E
My Output should look like below:
A
B
C
The Steading|Keir Allan|Braco
E
My requirement is to skip the delimiter if it is preceded by the escape sequence. I have tried the following using negative lookbehinds in String.split()
:
(?<!\\)\|
But, my problem is the delimiter will be defined by the end user dynamically and it need not be always |
. It can be any character on the keyboard (no restrictions). Hence, my doubt is that the above regex might fail for some of the special characters which are not allowed in regex.
I just wanted to know if this is the perfect way to do it.