ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Mitchell <>
Subject Re: How to convert back slashes to forward slashes
Date Thu, 09 Aug 2007 18:48:56 GMT

Peter Reilly wrote:

>On 8/9/07, broken connection <> wrote:
>>Hi Friends,
>>I take a directory path input from the end-user and store it in a
>>property,for example if its windows,it stores it as:
>This is not a valid property format: see
>so how do you store it?
Maybe not, but if you do <property name="log4j.location" 
location="C:\tomcat\logs"/> on windows (of course), you will get exactly 
what he describes.  Also, if you use an input task, like it sounds like 
he is doing, this is perfectly viable.

I use the ant-contrib propertyregex, such as:

<propertyregex property="log4.location.2" input="${log4j.location}" 
regexp="\\" replace="\\\\\\\\"/>

Yes, all of those backslashes are necessary in the replace.  Don't ask 
me why.  I assume they are getting de-referenced twice.  It's not well 
documented.  I had to figure it out the hard getting obtuse 
errors and tweaking ramdomly until they went away.

See for more.

Also, it depends on what you are doing with the property whether any of 
this matters or not.  Most tasks happily accept the single backslashes.

Geoffrey Mitchell
Home Decorator's Collection

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message