sS regexpQuote_useBackslashes(S s) { if (s == null) null; StringBuilder buf = null; int n = l(s); for i to n: { char c = s.charAt(i); if (regexpSpecialCharacters().indexOf(c) < 0) { if (buf != null) buf.append(c); } else { if (buf == null) buf = new StringBuilder(takeFirst(i, s)); buf.append('\\'); buf.append(c); } } ret buf == null ? s : buf.toString(); }