【发布时间】:2012-03-29 06:01:15
【问题描述】:
从我的数组字符串中的调试器我得到这个:
"/mercedes-benz/190-class/1993/" class="canonicalLink" data-qstring="?sub=sedan">1993
我希望在每个'/' 之后拆分文本并将其放入string[],这是我的努力:
Queue<string> see = new Queue<string>(); //char[] a = {'\n '};
List<car_facts> car_fact_list = new List<car_facts>();
string[] car_detail;
foreach (string s in car)
{
MatchCollection match = Regex.Matches(s, @"<a href=(.+?)</a>",
RegexOptions.IgnoreCase);
// Here we check the Match instance.
foreach(Match mm in match)
{
// Finally, we get the Group value and display it.
string key = mm.Groups[1].Value;
//key.TrimStart('"');
//key.Trim('"');
key.Trim();
// @HERE: I tried with string.Split as well and tried many combinations of separators
car_detail = Regex.Split(key, "//");
see.Enqueue(key);
}
}
在car_detail[0] 我得到这个"$[link]">$[title]
来自这个字符串:
"/mercedes-benz/190-class/1993/" class="canonicalLink" data-qstring="?sub=sedan">1993
【问题讨论】: