• 在字符串中找含HTTP连接字符串的代码


          代码如下:

          private string GetHttpStr(string str, string httpStr)
            {
                bool Ishavevalue = false;
                int newlength = httpStr.Length;
                string newstr = null;

                string httpendString = "<";
                 if (str.Length >= newlength && str.Contains(httpStr))
                {
                    newstr = str.Substring(str.IndexOf(httpStr, StringComparison.OrdinalIgnoreCase) + newlength);
                }
                int startindex = 0;
                startindex = str.IndexOf(httpStr, StringComparison.OrdinalIgnoreCase);
                int lengthindex = 0;
                string returnvalue = null;
                if (startindex >= 0)
                {
                    if (newstr.IndexOf('"') != -1 && newstr.IndexOf('"') <= newstr.IndexOf(httpendString))
                    {
                        lengthindex = newstr.IndexOf('"') + newlength;
                    }
                    else if (newstr.IndexOf('"') == -1 && newstr.IndexOf(httpendString) == -1)
                    {
                        lengthindex = str.Length;
                    }
                    else
                    {
                        lengthindex = newstr.IndexOf(httpendString) + newlength;
                    }
                    if (lengthindex == (newlength - 1))
                    {

                        lengthindex = newstr.IndexOf(httpendString) + newlength;
                    }
                    returnvalue = str.Substring(startindex, lengthindex);
                    Ishavevalue = true;
                }
                returnvalue = ReplaceSpecialUrl(returnvalue);
                return returnvalue + "  " + ((startindex + lengthindex) < str.Length && startindex > 0 && Ishavevalue ? GetHttpStr(str.Substring(startindex + lengthindex), httpStr) : null);

            }

    因为HTTP连接在html都是以"结束或者<结束,所以根据传入的httpStr样式不区分大小写方式把字符串str含有的以递归的方式找出来。

  • 相关阅读:
    struts2第一天——入门和基本操作
    eclipse各种小图标含义
    复制web项目时注意修改web项目名
    AndroidCityPicker仿IOS选择效果
    每日五题(Spring)
    block-循环引用
    给EasyUi的Form加入自己主动填充部分输入框的方法
    智能停车O2O 独角兽初现:“ETCP停车”获5000万美金A轮融资
    解决移动端页面滚动后不触发touchend事件
    《从零開始学Swift》学习笔记(Day 61)——Core Foundation框架之内存管理
  • 原文地址:https://www.cnblogs.com/springyangwc/p/1956342.html
Copyright © 2020-2023  润新知