C# GetValueList 獲得字符串中開始和結束字符串中間得值列表
阿新 • • 發佈:2017-05-27
mat 字符串 開始 true private ref uri cnblogs 字符
/// <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); }
用法
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"; }
C# GetValueList 獲得字符串中開始和結束字符串中間得值列表