sS dropSpaceEtc(S s) { elegant { ret filterChars(c -> !isSpaceEtc(c), s); } inlined { replace test with !isSpaceEtc . if (empty(s)) null; int n = l(s), i = 0; char c = s.charAt(i); bool totality = test(c); for (++i; i < n; i++) { c = s.charAt(i); bool b = test(c); if (b != totality) { // diverse case new StringBuilder buf; if (totality) buf.append(substring(s, 0, i)); while ping (true) { if (b) buf.append(c); if (++i >= n) break; c = s.charAt(i); b = test(c); } ret buf.toString(); } } ret totality ? s : ""; } }