You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jakob <ja...@jfix.com> on 2004/03/23 17:02:24 UTC

regexp contains "<" and ">" ...

Hi,

I am using Ant 1.6.0, and I would like to use Ant's
regular expression task <replaceregexp/> to modify an XML
file.  I know that this is not the ideal way to do this,
but this is a mixed-content issue for which XSLT is not
really appropriate.  Apparently, the problem is that the
reserved character "<" is used inside an attribute value
...


I would like to change this regexp

([^\s]+)<SUB>([^<]+)</SUB>

with this:

<dy:sym>\1<SUB>\2</SUB></dy:sym>


I have tried these:

<replaceregexp flags="g" byline="false">
  <regexp pattern="([^\s]+)<SUB>([^<]+)</SUB>"/>
  <substitution
expression="<dy:sym>\1<SUB>\2</SUB></dy:sym>"/>
  <fileset dir="test"><includes="test.xml"/></fileset>
</replaceregexp>

E:\test\build.xml:167: The value of attribute "pattern"
associated with an element type "regexp" must not contain
the '<' character.

<replaceregexp flags="g" byline="false">
  <regexp><![CDATA[([^\s]+)<SUB>([^<]+)</SUB>]]></regexp>
  <substitution><![CDATA[<dy:sym>\1<SUB>\2</SUB></dy:sym>]]></substitution>
  <fileset dir="test"><include name="test.xml"/></fileset>
</replaceregexp>

E:\test\build.xml:173: The <regexp> type doesn't support
nested text data.


Is there a way to do this in Ant, or should/must I call an
external task?

Thanks in advance,
Jakob.




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org