2014-05-12 41 views
0

我想用Ant來刪除xml文件中的url參數。Ant任務替換轉義的URI參數

xml中的行與以下類似。

<from uri="http://www.google.com?q=test&amp;somethingElse=something" /> 

我想刪除「& somethingElse = something」。 「某物」可能是不同的值,所以它必須是通用的。

我已經試過

<replaceregexp file="somefile.xml" match="&amp;somethingElse(.*)" replace='" />' flags="gs" byline="true" /> 

<replaceregexp file="somefile.xml" match="\&amp;somethingElse(.*)" replace='" />' byline="true" /> 

<replaceregexp file="somefile.xml" match="(&amp;)somethingElse(.*)" replace='" />' flags="gs" byline="true" /> 

但這些似乎並沒有工作。

$(ant.regexp.regexpimpl)未設置,因此正在使用默認引擎。

回答

1

爲了得到&,您需要在Ant構建文件中編寫&amp;,因爲它是XML。要在replaceregexp Ant任務的輸入中匹配&amp;somethingElse,您因此可能需要在Ant構建文件中指定&amp;amp;somethingElse