Pregunta

I'm trying to use Ant to remove a url parameter in an xml file.

The line in the xml is similar to below.

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

I want to remove the "&somethingElse=something". "something" could be different values so it must be generic.

I've tried

<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" />

but those don't seem to work.

$(ant.regexp.regexpimpl) is not set so the default engine is being used.

¿Fue útil?

Solución

In order to get & you need to write &amp; in the Ant build file because it is XML. To match &amp;somethingElse in the input of the replaceregexp Ant task you might therefore need to specify &amp;amp;somethingElse in the Ant build file.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top