在ant中,如何使用replace来删除<link />标签?

时间:2014-02-22 16:52:48

标签: ant replace

我正在尝试删除index.html中的标记,但是我发现以下错误:

<replace file="${build.dir}/${app.page.name}" token='<link rel="stylesheet" href="resources/AMC-all.css"/>' value=""/>

The value of attribute "token" associated with an element type "null" must not contain the '<' character.

2 个答案:

答案 0 :(得分:0)

这解决了它:

<fileset id="html.fileset"
    dir="${build.dir}"
    includes="${app.page.name}"/>

<replaceregexp replace="" flags="g"
    match='\&lt;\s*link\s*rel="stylesheet"\s*href=".*-all.css"\/\&gt;'>
    <fileset refid="html.fileset"/>
</replaceregexp>

答案 1 :(得分:0)

没有正则表达式的其他解决方案:

<replace dir="${out.dir}" encoding="utf8">
    <replacetoken><![CDATA[//<debug>]]></replacetoken>
    <replacevalue><![CDATA[/*<debug>]]></replacevalue>
</replace>