ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Ant replaceregexp match="$" replace="\n\$" erroneous behaviour ?
Date Thu, 25 Mar 2004 07:00:57 GMT
On Wed, 24 Mar 2004, Matt Benson <gudnabrsam@yahoo.com> wrote:
> --- denisboutin@free.fr wrote:
>>  <replaceregexp
>> file="installTurlututuEarWASReadable.jacl"
>> match="\$"
>> replace="\n\$" flags="g"/>
>> 
>> However, I've got the following exception :
>> BUILD FAILED
>> java.lang.StringIndexOutOfBoundsException: String
>> index out of range: 2
> 
> Looks like a bug in Ant regarding the oobe...

Yes, but an old one, since Denis is using Ant 1.5.  There was a bug in
the code that tries to expand properties when the String ended in an
$.

> however, the proper way to escape a '$' is to double it.  '\$' is
> incorrect.

Not really, Denis needs both escapes in Ant 1.5 and probably only one
$ in Ant 1.6.x (or 1.5.4 for that matter).

The \ is needed to escape the $ for the regexp engine since it is a
special character for regexps.  For Ant 1.5 you'd need \$$ and for
more a recent version of Ant \$ should be enough.

Stefan
-- 
http://stefanbodewig.blogger.de/

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


Mime
View raw message