In Java, I'm using the String split method to split a string containing values separated by semicolons.
Currently, I have the following line that works in 99% of all cases.
String[] fields = optionsTxt.split(";");
However, the requirement has been added to include escaped semicolons as part of the string. So, the following strings should parse out to the following values:
"Foo foo;Bar bar" => [Foo foo] [Bar bar]
"Foo foo\; foo foo;Bar bar bar" => [Foo foo\; foo foo] [Bar bar bar]
This should be painfully simple, but I'm totally unsure about how to go about it. I just want to not tokenize when there is a \; and only tokenize when there is a ;.
Does anyone out there know the magic formula?