c#中用于搜索文本中多行表达式的优化正则表达式
我试图在文本文件中找到以下类型的表达式:c#中用于搜索文本中多行表达式的优化正则表达式,c#,regex,winforms,C#,Regex,Winforms,我试图在文本文件中找到以下类型的表达式: <<>[some text][newline][some text]<>> 找到被单行分割的表达式非常有效,但我还需要找到被各行分割的表达式 我也试过下面的表达: (.**?\n.**?* 但是搜索它会导致超时, 请帮忙 用于搜索的示例文本: <p class=3DMsoNormal style=3D'margin-top:12.0pt;margin-right:0cm;margin-bot= t
<<>[some text][newline][some text]<>>
找到被单行分割的表达式非常有效,但我还需要找到被各行分割的表达式
我也试过下面的表达:
(.**?\n.**?*
但是搜索它会导致超时,
请帮忙
用于搜索的示例文本:
<p class=3DMsoNormal style=3D'margin-top:12.0pt;margin-right:0cm;margin-bot=
tom:
0cm;margin-left:148.85pt;margin-bottom:.0001pt;text-indent:-148.85pt;
tab-stops:148.85pt right 16.0cm'><b style=3D'mso-bidi-font-weight:normal'><=
span
style=3D'font-family:"Calibri","sans-serif"'>RISK DETAILS<span style=3D'mso=
-tab-count:
1'> =
&nb=
sp; =
</span></span></b><span
style=3D'font-family:"Calibri","sans-serif"'>Your home is described as
<q_1><o:p></o:p></span></p>
<p class=3DMsoNormal style=3D'margin-top:0cm;margin-right:0cm;margin-bottom=
:0cm;
margin-left:148.85pt;margin-bottom:.0001pt'><span style=3D'font-family:"Cal=
ibri","sans-serif"'>The
construction of your home is <q_2><o:p></o:p></span></p>
<p class=3DMsoNormal style=3D'margin-top:0cm;margin-right:0cm;margin-bottom=
:0cm;
margin-left:148.85pt;margin-bottom:.0001pt'><span style=3D'font-family:"Cal=
ibri","sans-serif"'>The
main roof material is <q_3><o:p></o:p></span></p>
<p class=3DMsoNormal style=3D'margin-top:0cm;margin-right:0cm;margin-bottom=
:0cm;
margin-left:148.85pt;margin-bottom:.0001pt'><span style=3D'font-family:"Cal=
ibri","sans-serif"'>Your
home was built in <q_4><o:p></o:p></span></p>
<p class=3DMsoNormal style=3D'margin-top:0cm;margin-right:0cm;margin-bottom=
:0cm;
margin-left:148.85pt;margin-bottom:.0001pt'><span style=3D'font-family:"Cal=
ibri","sans-serif"'>Your
<span class=3DGramE>home <q_5> double</span> keyed deadlocks to all
external doors<o:p></o:p></span></p>
<p class=3DMsoNormal style=3D'margin-top:0cm;margin-right:0cm;margin-bottom=
:0cm;
margin-left:148.85pt;margin-bottom:.0001pt'><span style=3D'font-family:"Cal=
ibri","sans-serif"'>Your
home <q_6> keyed locks or grilles on all windows<o:p></o:p></span></p>
<p class=3DMsoNormal style=3D'margin-top:0cm;margin-right:0cm;margin-bottom=
:0cm;
margin-left:148.85pt;margin-bottom:.0001pt'><span style=3D'font-family:"Cal=
ibri","sans-serif"'>Your
home has <q_7> alarm installed<o:p></o:p></span></p>
<p class=3DMsoNormal style=3D'margin-top:0cm;margin-right:0cm;margin-bottom=
:0cm;
margin-left:148.85pt;margin-bottom:.0001pt'><span style=3D'font-family:"Cal=
ibri","sans-serif"'>Your
home <q_8> connected to mains water supply<o:p></o:p></span></p>
风险详情=
&铌=
sp=
你的家被描述为
问题1
你家的建筑是q_2
主要屋顶材料为q_3
这座房子是在q_4建造的
home q_5双钥匙死锁适用于所有人
外门
所有窗户上的家用q_6钥匙锁或格栅
home安装了q_7报警器
住宅q_8连接到主供水系统
一些例子:
例1:
要搜索的文本:
<span
style=3D'color:blue'><o:p></o:p></span></span></p>
</td>
<td width=3D103 valign=3Dtop style=3D'width:77.5pt;padding:0cm 5.4pt 0cm =
0cm'>
<p class=3DMsoNormal align=3Dright style=3D'margin-top:3.0pt;margin-right=
:0cm;
margin-bottom:0cm;margin-left:0cm;margin-bottom:.0001pt;text-align:right;
tab-stops:155.95pt'><span style=3D'font-family:"Calibri","sans-serif"'><=
<span
class=3DSpellE>spec_contents_value</span>><span style=3D'color:blue'><=
o:p></o:p></span></span></p>
</td>
</tr>
</table>
<p class=3DMsoNormal style=3D'margin-top:0cm;margin-right:0cm;margin-bottom=
:0cm;
margin-left:148.85pt;margin-bottom:.0001pt;text-indent:-148.85pt;tab-stops:
148.85pt right 453.55pt'><span style=3D'font-family:"Calibri","sans-serif"'=
><o:p> </o:p></span></p>
<p class=3DMsoNormal style=3D'margin-top:0cm;margin-right:0cm;margin-bottom=
:0cm;
margin-left:148.85pt;margin-bottom:.0001pt;text-indent:-148.85pt;tab-stops:
148.85pt right 453.55pt'><span style=3D'font-family:"Calibri","sans-serif"'=
>Unspecified
Valuables<b style=3D'mso-bidi-font-weight:normal'><span style=3D'mso-tab-co=
unt:
1'> =
</=
span></b><valuables><o:p></o:p></span></p>
<p class=3DMsoNormal style=3D'margin-top:0cm;margin-right:0cm;margin-bottom=
:0cm;
margin-left:148.85pt;margin-bottom:.0001pt;text-indent:-148.85pt;tab-stops:
148.85pt right 453.55pt'><span style=3D'font-family:"Calibri","sans-serif"'=
>Specified
Valuables<b style=3D'mso-bidi-font-weight:normal'><span style=3D'mso-tab-co=
unt:
1'> =
&nb=
sp; </span></b><<spanclass=3DSpellE>spec_valuables_ni</span>>=
<o:p></o:p></span></p>
=
规格内容值
规定
贵重物品=
&铌=
服务提供商;贵重物品规格=
我希望我的Regex.Match模式能够搜索:
<=
<span
class=3DSpellE>spec_contents_value</span>>
=
规格内容值
或<…>跨越多条线的图案。但不是同一条线上的人 使用点所有修改器使点与偶数换行符匹配(
\n
,\r
)
正则表达式怎么样
<[^&]*>
比如说
匹配
匹配除[^&]*
以外的任何内容,包括换行符&
匹配
(?s)
操作符,使用
匹配任何内容
输入
<=
<span
class=3DSpellE>spec_contents_value</span>>
=
规格内容值
它将匹配为格式化您的代码,以便我们可以提供您想要的正则表达式。感谢@nu11p01n73R的编辑:-)@MOHIST00691是<还是<在您的原始代码中?@nu11p01n73R您的编辑使它正确了<。Hi@Avunash Raj first表达式工作正常,但它也在搜索文本时没有嵌入换行符,是否可以添加一些内容以使其搜索包含至少一个换行符的事件?它现在跳过了一些事件,我已附加了一个示例文本用于搜索我的问题。您可以发布预期的输出吗?非常感谢@Avinash Raj
<[^&]*>
<=
<span
class=3DSpellE>spec_contents_value</span>>