在xml中匹配多行匹配模式

时间:2013-01-30 06:56:52

标签: regex sublimetext2

如何匹配以下模式:

<aaa class = "dog">
   <bbb id = "one"/>
</aaa>
<aaa class = "dog">
   <bbb id = "two"/>
</aaa>
<aaa class = "dog">
   <bbb id = "three"/>
</aaa>

我想:

<aaa class = "dog">
   <bbb id = "three"/>
</aaa>

我用:

^(.)*dog(.|\r|\n|\t)*(three)

但匹配:

<aaa class = "dog">
   <bbb id = "one"/>
</aaa>
<aaa class = "dog">
   <bbb id = "two"/>
</aaa>
<aaa class = "dog">
   <bbb id = "three

我应该如何编辑正则表达式以匹配我想要的内容?

1 个答案:

答案 0 :(得分:1)

如果你想匹配上面提到的三行,你可以使用以下正则表达式:

<aaa class = "dog">[\r\n\t\s]*<bbb id = "three"/>[\r\n\t\s]*</aaa>