【发布时间】:2008-09-17 01:35:40
【问题描述】:
我正在 .NET 项目中处理正则表达式以获取特定标签。我想匹配整个 DIV 标签及其内容:
<html>
<head><title>Test</title></head>
<body>
<p>The first paragraph.</p>
<div id='super_special'>
<p>The Store paragraph</p>
</div>
</body>
</head>
代码:
Regex re = new Regex("(<div id='super_special'>.*?</div>)", RegexOptions.Multiline);
if (re.IsMatch(test))
Console.WriteLine("it matches");
else
Console.WriteLine("no match");
我想匹配这个:
<div id="super_special">
<p>Anything could go in here...doesn't matter. Let's get it all</p>
</div>
我认为. 应该获取所有字符,但回车似乎有问题。我的正则表达式缺少什么?
谢谢。
【问题讨论】: