zoukankan      html  css  js  c++  java
  • .net中 过滤 指定 字符串


            /// <summary>
            /// 过滤字符
            /// </summary>
            /// <param name="Input"></param>
            /// <returns></returns>
            public static string Filter(string sInput)
            {
                if (sInput == null || sInput == "")
                    return null;
                string sInput1 = sInput.ToLower();
                string output = sInput;
                string pattern = @"*|and|exec|insert|select|delete|update|count|master|truncate|declare|char(|mid(|chr(|'";
                if (Regex.Match(sInput1, Regex.Escape(pattern), RegexOptions.Compiled | RegexOptions.IgnoreCase).Success)
                {
                    throw new Exception("字符串中含有非法字符!");
                }
                else
                {
                    output = output.Replace("'", "''");
                }
                return output;
            }
  • 相关阅读:
    线段的类
    计算三角形的类
    关于狗的类
    [poj2234] Matches Game
    bzoj[2655] calc
    拉格朗日插值和牛顿插值 菜鸟教程
    NOI模拟赛(3.15) sequence(序列)
    NOI模拟赛(3.13)Hike (远行)
    二分图讲解
    NOI模拟赛(3.8)Problem B
  • 原文地址:https://www.cnblogs.com/mahaisong/p/1964896.html
Copyright © 2011-2022 走看看