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

  • 相关阅读:
    python爬虫 -掘金
    python 爬取简书评论
    python爬取知乎评论
    python 爬取链家
    python爬虫获取下一页
    python正则找到字符串里面的数字
    faker切换user-agent
    python 爬虫可视化函数,可以先看看要爬取的数据是否存在
    acwing 471. 棋盘 解题记录
    ACWING 95 费解的开关 解题记录
  • 原文地址:https://www.cnblogs.com/lmcblog/p/2596514.html
Copyright © 2011-2022 走看看