zoukankan      html  css  js  c++  java
  • 过滤特殊字符

     /// <summary>
            /// 过滤特殊字符
            /// </summary>
            /// <param name="str"></param>
            /// <returns></returns>
            public static string FilterSpecial(this string str)
            {
                if (str == string.Empty) //如果字符串为空,直接返回。
                {
                    return str;
                }
                else
                {
                    str = str.Replace("'", string.Empty);
                    str = str.Replace("<", string.Empty);
                    str = str.Replace(">", string.Empty);
                    //str = str.Replace("%", string.Empty);
                    str = str.Replace("'delete", string.Empty);
                    str = str.Replace("''", string.Empty);
                    str = str.Replace(",", string.Empty);
                    str = str.Replace(".", string.Empty);
                    str = str.Replace(">=", string.Empty);
                    str = str.Replace("=<", string.Empty);
                    str = str.Replace("-", string.Empty);
                    str = str.Replace("_", string.Empty);
                    str = str.Replace(";", string.Empty);
                    str = str.Replace("||", string.Empty);
                    str = str.Replace("[", string.Empty);
                    str = str.Replace("]", string.Empty);
                    str = str.Replace("&", string.Empty);
                    str = str.Replace("/", string.Empty);
                    str = str.Replace("-", string.Empty);
                    str = str.Replace("|", string.Empty);
                    str = str.Replace("?", string.Empty);
                    str = str.Replace(">?", string.Empty);
                    str = str.Replace("?<", string.Empty);
                    str = str.Replace(" ", string.Empty);
                    return str;
                }
            }

  • 相关阅读:
    js 数组相减
    js 对象数组去重
    vue 首次不触发watch的解决方法
    "神药"推荐--紫花地丁
    openstack 平台添加 nvidia vGPU
    string易错点整理总结
    CentOS安装图形界面
    CentOs安装ssh和scp
    数组把0移到末尾
    Windows下Celery安装与下使用
  • 原文地址:https://www.cnblogs.com/lmcblog/p/2596514.html
Copyright © 2011-2022 走看看