111,126
社区成员
发帖
与我相关
我的任务
分享
<div class="content">1212221</div>
<div class="content">fdsa</div>
<div class="content">fdsa1</div>
List<string> listpath = new List<string>();
string strfromtxt = File.ReadAllText(@"C:\1.txt", Encoding.GetEncoding("GB2312"));
string contentRef = @"<div\s*class=""content""[^>]*>(?<content>(.*))</div>";
MatchCollection matches = Regex.Matches(strfromtxt,contentRef);
foreach (Match match in matches)
{
string contemp = match.Groups["content"].Value.Trim();
listpath.Add(contemp);
}
string sss = "<div class=\"content\">1234567</div><div class=\"content\">abcde</div>";
MatchCollection matches = Regex.Matches(sss, @"(?i)(?<=class=""content"">)(.+?)(?=</div>)");
foreach (Match match in matches)
{
Response.Write(match.Value + "<br />");
}