// does not return unclosed strings static L findSubstringsEnclosedBy(S s, char a, char b) { int i = 0; new L l; while ((i = indexOf(s, a, i)) >= 0) { int j = indexOf(s, b, i+1); if (j < 0) break; l.add(substring(s, i, j+1)); i = j+1; } ret l; }