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;
            }
  • 相关阅读:
    express 连接 moogdb 数据库
    数组 去重
    vue 路由meta 设置title 导航隐藏
    :src 三目运算
    axios baseURL
    js对象修改 键
    Swiper隐藏后在显示滑动问题
    字符串中的替换
    获取服务器时间
    vue a链接 添加参数
  • 原文地址:https://www.cnblogs.com/mahaisong/p/1964896.html
Copyright © 2011-2022 走看看