public static string Replace(string oldStr) { if (string.IsNullOrEmpty(oldStr)) { return ""; } string str2 = Regex.Replace(oldStr, @"[\[\+\\\|\(\)\^\*\""\]'%~#-&]", delegate(Match match) { if (match.Value == "'") { return "''"; } else { return "[" + match.Value + "]"; } }); return str2; }
常见的特殊字符 基本都能转义 ,布吉岛 还有没有漏掉的 ,目前使用正常 。spa