Implementing logic in a different way
Below code is more readable and no need of using our logic around single quotes.

String[] w = fqField.split("\"");
for (int i = 1; i &lt; w.length; i+=2) {
    prefixes.add(w[i]);
}