In Java, I use the line splitting method to split a string containing values separated by a semicolon.
Currently, I have the following line, which works in 99% of all cases.
String[] fields = optionsTxt.split(";");
However, a requirement has been added to include semicolons as part of the string. So, the following lines should analyze 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]
It should be excruciatingly simple, but I'm completely not sure how to do it. I just want to not tokenize when there is \; and only tokenize when there is :.
Does anyone know a magic formula?
source
share