匹配内容<%@ Page Language="C#" MasterPageFile="~/Content/Default.master" AutoEventWireup="true" CodeFile="Add.aspx.cs" Inherits="Temp_Add" %><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
内容1
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PositionPlaceHolder" runat="Server">
内容2
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainPlaceHolder" runat="Server">
内容3
</asp:Content>
我想匹配<asp:Content>节点的内容与属性,
要求结果如下:
属性:ID="Content1" ContentPlaceHolderID="head" runat="Server"
内容:内容1我尝试着分组匹配,似乎匹配不到 string html ="字符串"
string pattern = "<asp:Content(?<Attribute>[^<]*?)>(?<content>.*?)</asp:Content>";
foreach (Match item in Regex.Matches(html, pattern))
{Response.Write(item.Groups["Attribute"].Value+"<br/>");
Response.Write(item.Groups["content"].Value + "<br/>");
Response.Write("=============================<br/>");
}
Response.End();求大神解决方案?
内容1
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PositionPlaceHolder" runat="Server">
内容2
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainPlaceHolder" runat="Server">
内容3
</asp:Content>
我想匹配<asp:Content>节点的内容与属性,
要求结果如下:
属性:ID="Content1" ContentPlaceHolderID="head" runat="Server"
内容:内容1我尝试着分组匹配,似乎匹配不到 string html ="字符串"
string pattern = "<asp:Content(?<Attribute>[^<]*?)>(?<content>.*?)</asp:Content>";
foreach (Match item in Regex.Matches(html, pattern))
{Response.Write(item.Groups["Attribute"].Value+"<br/>");
Response.Write(item.Groups["content"].Value + "<br/>");
Response.Write("=============================<br/>");
}
Response.End();求大神解决方案?
解决方案 »
- 请教 iis 配置问题 ?
- 求将图片路径存储到sql里的源代码
- LDAP怎样获取AD域中指定组的所有用户
- 配置select语句里的“高级” 生成insert,update,delete语句这个选项是灰的,不能选
- 大家看看这个问题怎么解决?
- 有关验证的问题,其实也不算是问题。从用.NET1.0版定的程序,用到1.1版上,验证没起作用。
- gridview中textbox的内容被修改后,需要鼠标点击两次才能到下一个控件
- .net连接ORACLE数据库提示错误ORA-06413连接未打开
- 请各位推荐一下深圳地区口碑较佳的一些软件/数据库研发的公司或机构...
- 关于java提示框在vb.net 中的应用。
- 求解怎么在 static 类中获取到当前页面的控件
- 关于gridview 里面使用模板列不能获取单元格的值问题
所以修正如下string pattern =@"<asp:Content(?<Attribute>[^<]*?)>(?<content>[\s\S]*?)</asp:Content>";
string pattern = "<asp:Content(?<Attribute>[^<]*?)>(?<content>[^<asp:Content]*?)</asp:Content>";//(.*)</asp:Content>
foreach (Match item in Regex.Matches(html, pattern))
{
Response.Write("属性:"+item.Groups["Attribute"].Value+"<br/>");
Response.Write("内容:"+item.Groups["content"].Value + "<br/>");
Response.Write("======================================================<br/>");
}
Response.End();