日期:2014-05-17 浏览次数:20906 次
/// <summary> /// 过滤字符 /// </summary> public static string Filter(string sInput) { if (sInput == null || sInput.Trim() == string.Empty) return null; string sInput1 = sInput.ToLower(); string output = sInput; string pattern = @",|.|?|!"; if (Regex.Match(sInput1, Regex.Escape(pattern), RegexOptions.Compiled | RegexOptions.IgnoreCase).Success) { throw new Exception("字符串中含有非法字符!"); } else { output = output.Replace("'", "''"); } return output; }