C# 正则验证 regcx.ismatch()非法字符验证
C# 正则验证 regcx.ismatch()非法字符验证 非法字符包括 , . ? !
谁给写个后面的参数
[解决办法]
/// <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;}