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;
                }
            }

  • 相关阅读:
    [BZOJ1492] [NOI2007]货币兑换Cash 斜率优化+cdq/平衡树维护凸包
    [BZOJ2638] 黑白染色
    [BZOJ2006] [NOI2010]超级钢琴 主席树+贪心+优先队列
    [BZOJ3698] XWW的难题 网络流
    [BZOJ2151] 种树 贪心
    js中的闭包理解一
    HTML5 input placeholder 颜色修改示例
    26 个 jQuery使用技巧
    JS原型与原型链(好文看三遍)
    文字和图片垂直居中
  • 原文地址:https://www.cnblogs.com/lmcblog/p/2596514.html
Copyright © 2011-2022 走看看