如我有正则表达式
<{this\.\S+?}>([\S\s]*?)<{/this\.\S+?}>
检索内容为
-------------------
<{this.header}>
我是头
<{/this.header}>
<{this.main}>
我是主要内容
<{/this.main}>
<{this.footer}>
我是尾
<{/this.header}>
-------------------
现在是可以的,但是不够严谨
如
<{this.header}><{/this.foot}>
也是过得了的那应该如何写最好呢?谢谢
<{this\.\S+?}>([\S\s]*?)<{/this\.\S+?}>
检索内容为
-------------------
<{this.header}>
我是头
<{/this.header}>
<{this.main}>
我是主要内容
<{/this.main}>
<{this.footer}>
我是尾
<{/this.header}>
-------------------
现在是可以的,但是不够严谨
如
<{this.header}><{/this.foot}>
也是过得了的那应该如何写最好呢?谢谢
解决方案 »
- 关于datalist里DropDownList的绑定。
- Visual Studio 2010 asp.net如何像 2008那样“发布网站”
- 小妹请教前辈们向Javascript传递值的问题!
- 为何asp.net做的东西没asp的稳定啊
- page_load执行两遍
- 问个低级问题!
- 高难度asp.net中button按钮的问题
- c#中关于验证控件问题!!希望有知情者告之!!谢谢
- 把数据库里的记录绑定在下拉菜单上,无论选择哪一项,提交时记录到数据库里得到的值为什么总是下拉菜单里的第一项?
- asp.net配置MySQL数据源
- 在asp.net ajax页面弹出新窗口
- 询问C#语言能够如何容易掌握和记住以下几点基础的方法。
<{this\.\S+?}>([\S\s]+?)<{/this\.\S+?}>
@"<{(this\.[^}]+)}>[^<>]*<{/\1}>"
--------
楼上这么测试不过
??!!
我是头
<{/this.header}>
<{this.main}>
我是主要内容
<{/this.main}>
<{this.footer}>
我是尾
<{/this.header}>
-----------------最后一个应该是<{/this.footer}>
MatchCollection mc = reg.Matches(yourStr);
foreach(Match m in mc)
{
richTextBox2.Text += m.Value + "\n-------------\n";
}
我是头
<{/this.header}>
<{this.main}>
我是主要内容
<{/this.main}>
<{this.footer}>
我是尾
<{/this.footer}>
<{this.header}><{/this.foot}>
";
Regex re = new Regex(@"<{([^}]+)}>([^<]*?)<{/\1}>");
MatchCollection mc = re.Matches(str);
foreach(Match m in mc)
Console.WriteLine(m.Value);这个是可以的
我是头
<{/this.header}>
<{this.main}>
我是主要内容
<{/this.main}>
<{this.footer}>
我是尾
<{/this.footer}>
<{this.header}><{/this.foot}>
";
Regex re = new Regex(@"(?is)<{this\.([^{}]+)}>(.*?)<{/this\.\1}>"); MatchCollection mc = re.Matches(str);
foreach(Match m in mc)
Console.WriteLine(m.Value);
不用Group的答案全部都可以踢飞掉^_^!