You will need to upgrade to ant 1.5.3-1
I don't the exact version where it's fixed, but there
was apparantly a problem with the way substititions were
being done, where the code was pulling a character beyond
the end of the string, giving an exception.  (The exception
happens when i run within IntelliJ, which uses it's own
ANT, but not when i use the 1.5.3-1 version).


Note:  That the "regexp" attribute needs you to double
the backslash character, as specified by the perl re syntax.
However, the replacement should be done as is, since it
is interperated as a literal string, with special processing
done for the backreference insertion.  ANT is not using the
native substite methods (such as org.apache.regexp.RE.substitute)


        <property name="p-in" value="\\abc\\def" />
        <echo message="${p-in}" />
        <propertyregex
            property="p-out"
            input="${p-in}"
            regexp="\\\\"
            replace="\"
            global="true" />

----------------
Matthew Inger [inger@synygy.com]
Software Developer
Synygy, Inc
610-664-7433 x 7770
"Man who jump off cliff, leap to conclusions." - Confucious


-----Original Message-----
From: Rutger Hofman [mailto:rutger@cs.vu.nl]
Sent: Thursday, September 04, 2003 1:29 PM
To: ant-contrib-developers@lists.sourceforge.net
Subject: Re: [Ant-contrib-developers] propertyregex: '\' within patterns


Why do I have to quadruplate the backslash? Why in replace and
not in regexp?
I would expect, to replace '\' with '\\':
   regexp="\\" replace="\\\\"             (2 and 4)
or if I must quadruplate, then I would expect
   regexp="\\\\" replace="\\\\\\\\"       (4 and 8)

It is like none of these. Specifying 8 '\' in replace also
gives the correct result. So, 2 and 8 is OK, as is 2 and 7.
However, 4 and 8 gives a failure to match the pattern:
4 apparently matches 2 '\' in the input string.

(In fact, I would not have been surprised if the seventh
backslash would have escaped the following end-quote, but ant
life seems not so simple.)

Greetz,

Rutger Hofman
VU Amsterdam

Inger, Matthew wrote:> Backslashes should be in increments of two if you're
> actually trying to represent the backslash character.
> So, you should probably have 8 backslashes.
>
> ----------------
> Matthew Inger [inger@synygy.com]
> Software Developer
> Synygy, Inc
> 610-664-7433 x 7770
> "Man who jump off cliff, leap to conclusions." - Confucious
>
>
> -----Original Message-----
> From: Rutger Hofman [mailto:rutger@cs.vu.nl]
> Sent: Thursday, September 04, 2003 12:13 PM
> To: ant-contrib-developers@lists.sourceforge.net
> Subject: [Ant-contrib-developers] propertyregex: '\' within patterns
>
>
> Another question about propertyregex.
>
> I want to basically set property p-out from replacing
> "\" with "\\" in some property, p-in. Now, '\' is of
> course escape character, so I must replace it. I would
> presume that regexp="\\" and replace="\\\\" would do
> the job.
>
> However, I must do:
>
> <propertyregex
>       property="p-out"
>       input="${p-in}"
>       regexp="\\"
>       replace="\\\\\\\"
>       global="true" />
>
> This is, yes, seven(!) backslashes in replace,
> where I would expect four.
>
> Other numbers of backslashes in replace lead to
>
> java.lang.StringIndexOutOfBoundsException: String index out of range: 3
>          at java.lang.String.charAt(String.java:460)
>          at java.util.regex.Matcher.appendReplacement(Matcher.java:544)
>
> or other errors.
>
> Any clue? Is this going to be required (and documented) behaviour,
> or is it a bug?
> If you want, I can spend some time to hunt down the bug (if my professor
> allows it :-)
>
> Rutger
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Ant-contrib-developers mailing list
> Ant-contrib-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ant-contrib-developers
>





-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Ant-contrib-developers mailing list
Ant-contrib-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ant-contrib-developers