【发布时间】:2015-02-08 17:04:01
【问题描述】:
我有一个 html,但索引很少。示例如下
this is first sample index <!-- @@struct1_s§var1-->19.5.1<!--Index--> and this is required
this is second sample index <!-- @@struct2_s§var2-->19.5.2<!--Index--> - this is extension to the sample index <!-- @@struct3_s§var3-->19.5.3<!--Index--> and this is required.
我使用正则表达式
"<!--\s?@{2}[\.\w]*§[\.\w\[.\]]+-->[\d]+\.[\d]+\.[\d]+<!--Index-->"
所以如果我解析上面的 html 部分,我会得到匹配
<!-- @@struct1_s§var1-->19.5.1<!--Index-->
<!-- @@struct2_s§var2-->19.5.2<!--Index-->
<!-- @@struct3_s§var3-->19.5.3<!--Index-->
现在我想改变我的正则表达式,如果存在的话,我想检索整个索引
因此,如果我解析了 html 的上述部分,我应该得到匹配为
<!-- @@struct1_s§var1-->19.5.1<!--Index-->
<!-- @@struct2_s§var2-->19.5.2<!--Index--> - <!-- @@struct3_s§var3-->19.5.3<!--Index-->
我正在尝试使用此表达式,但它也会检索同一行中存在的其他字符
regEx.Pattern = "<!--\s?@{2}[\.\w]*§[\.\w\[.\]]+-->[\d]+\.[\d]+\.[\d]+<!--Index-->[-\s?]?[<!--\s?@{2}[\.\w]*§[\.\w\[.\]]+-->[\d]+\.[\d]+\.[\d]+<!--Index-->]?"
如果有人可以帮我解决这个问题。
【问题讨论】:
-
<!--.*<!--Index--> -
vks 能不能给我完整的表达方式
-
它没有出现。也许你需要把它们放在花括号之间