public static string Title(string html)
{
Regex str = new Regex(@"<div class="title3"><div>.*?</div></div>", RegexOptions.IgnoreCase);
Match m = str.Match(html); if (m.Success)
{
return m.Value;
}
return m.Value;
}
请问这里怎么输出<div class="title3"><div>内容</div></div> 中间div里面的“内容”。还有一个小小问题,怎么加双引号?"title3" 这样程序要出错,而'title3'就不会出错
Regex re = new Regex(@"(?<=<div style=""title3""><div>).*(?=</div><div>)",
Match m = reg.Match("");
if (m.Success)
{
TextBox1.Text = m.Value;
}
void Main()
{
//Regex str = new Regex(@"(?is)(<div[^>]*>){2}(?<txt>[^<>]+)(</div>){2}");
Regex str=new Regex(@"(?is)<div[^>]*class=""title3""><div>(?<txt>[^<>]+)(</div>){2}");
Match m = str.Match(@"<div class=""title3""><div>内容</div></div>"); if (m.Success)
{
Console.WriteLine( m.Groups["txt"].Value); //内容
}
}