C# GetValueList 获得字符串中开始和结束字符串中间得值列表

1
2
3
4
5
6
7
8
9
/// <summary>
/// 获得字符串中开始和结束字符串中间得值列表
/// </summary>
/// <param name="styleContent">样式内容</param>
/// <returns></returns>
private MatchCollection GetValueList(string str, string s, string e)
{
    return Regex.Matches(str, "(?<=(" + s + "))[.\\s\\S]*?(?=(" + e + "))", RegexOptions.IgnoreCase);
}

用法

1
2
3
4
5
6
7
8
MatchCollection HrefList = this.GetValueList(listHtml, ListHrefBegin, ListHrefEnd);
foreach (Match match in HrefList)//循环获取
{
    if (match.Value.StartsWith("/"))
        list += "http://" + uri.Host + match.Value + "\r\n";
    else
        list += match.Value + "\r\n";
}

  

posted @   懒人境界  阅读(970)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示