Ant replaceregexp匹配多行

时间:2014-07-18 13:49:29

标签: regex ant

匹配并替换此任何实例:

     </topichead>
<topicref

在ant中使用replaceregexp,为什么这不起作用?

   <replaceregexp byline="false" flags="gis">
     <regexp pattern="&lt;/topichead&gt;\n&lt;topicref"/>
     <substitution expression="&lt;topicref"/>
     <fileset dir=".">
     <include name="*.txt"/>
     </fileset>
   </replaceregexp> 

如果我只在一行上匹配并替换&lt;/topichead&gt;作为测试,则该任务有效。

我的\n显然无法匹配新的线路标记。我在那里试过\r\n,我也试过了$ {line.separator},但任务的结果没有变化。

如果我将正则表达式放在regex101.com中,就像这样:

</topichead>\n<topicref

它告诉我它符合这个内容:

     </topichead>
<topicref

如果我以regex101.com这样做:

(</topichead>)(\n)(<topicref)

然后它将内容与三个捕获组匹配。很明显它在那里工作,为什么不在Ant构建中呢?

0 个答案:

没有答案
相关问题