static L ocr_parseGroups(S s) { new L l; for i over s: if (s.charAt(i) == '\\' && i+1 < l(s)) { // parse escaped character ++i; l.add(substring(s, i, i+1)); } else if (s.charAt(i) == '[') { // parse group int j = i+1; new StringBuilder buf; while (j < l(s) && s.charAt(j) != ']') { if (s.charAt(j) == '\\' && j+1 < l(s) && eqOneOf(s.charAt(j+1), '[', ']')) ++j; buf.append(s.charAt(j++)); } l.add(str(buf)); i = j; } else l.add(substring(s, i, i+1)); ret l; }