Regex re = new Regex("(?<=<title>).*?(?=</title>)", RegexOptions.None); MatchCollection mc = re.Matches("你的字符串"); foreach (Match ma in mc) { //ma.Value就是你要的值 }
(?<=<title[^<>]*?>)(?<content>[^<]*?)(?=</title>)
Regex re = new Regex("(?<=<title>).*?(?=</title>)", RegexOptions.None); MatchCollection mc = re.Matches("<title><div>afdadfa</div></title>"); foreach (Match ma in mc) { Response.Write( Server.HtmlEncode(ma.Value)); } //引用1楼
MatchCollection mc = re.Matches("你的字符串");
foreach (Match ma in mc)
{
//ma.Value就是你要的值
}
MatchCollection mc = re.Matches("<title><div>afdadfa</div></title>");
foreach (Match ma in mc)
{
Response.Write( Server.HtmlEncode(ma.Value));
}
//引用1楼
督查真会逗乐...title嵌套?