java: public static String quote(String string) {StringBuilder sb = new StringBuilder();sb.append("\\Q");int apos = 0;int k;while ((k = string.indexOf("\\E", apos)) >= 0) {sb.append(string.substring(apos, k + 2)).append("\\\\E\\Q");apos = k + 2;}return sb.append(string.substring(apos)).append("\\E").toString();}
C#: public static string quote(string @string){java.lang.StringBuilder sb = new java.lang.StringBuilder();sb.append("\\Q");int apos = 0;int k;while ((k = @string.IndexOf("\\E", apos)) >= 0){sb.append(Sharpen.StringHelper.Substring(@string, apos, k + 2)).append("\\\\E\\Q");apos = k + 2;}return sb.append(Sharpen.StringHelper.Substring(@string, apos)).append("\\E").ToString();}