int (String text, int start) { boolean slash = false; final int max = text.length() - 1; // skip closing " for (int i = start; i < max; i++) { final char c = text.charAt(i); if (slash) { slash = false; if (c == '\'') return i - 1; } else if (c == '\\') slash = true; } return -1; }