question related to this
I have a string
a\\;b\\\\;c;d
which in Java looks like
String s = \"a\\\\;b\\\\\\\\;c;d\"
I do not trust to detect those cases with any kind of regular expression. I usually do a simple loop for such things, I'll sketch it using C
since it's ages ago I last touched Java
;-)
int i, len, state;
char c;
for (len=myString.size(), state=0, i=0; i < len; i++) {
c=myString[i];
if (state == 0) {
if (c == '\\') {
state++;
} else if (c == ';') {
printf("; at offset %d", i);
}
} else {
state--;
}
}
The advantages are: