求用正则表达式过滤风险字符 如过滤逗号,句号

解决方案 »

  1.   

    如果纯粹过滤非得用正则?
    replace不行?
      

  2.   

    public static string ReplaceSQLChar(string str)
            {
                if (str == String.Empty)
                    return String.Empty;            str = str.Replace("'", "‘");
                str = str.Replace(";", ";");
                str = str.Replace(",", ",");
                str = str.Replace("?", "?");
                str = str.Replace("<", "<");
                str = str.Replace(">", ">");
                str = str.Replace("(", "(");
                str = str.Replace(")", ")");
                str = str.Replace("@", "@");
                str = str.Replace("=", "=");
                str = str.Replace("+", "+");
                str = str.Replace("*", "*");
                str = str.Replace("&", "&");
                str = str.Replace("#", "#");
                str = str.Replace("%", "%");
                str = str.Replace("$", "¥");            return str;
            }