ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject RE: Replacing chars in a property
Date Thu, 15 Nov 2007 08:12:06 GMT
 
-----Original Message-----
From: Nicolai Kamenzky [mailto:kamenzky@inf.fu-berlin.de] 
Sent: Wednesday, November 14, 2007 4:43 PM
To: user@ant.apache.org
Subject: Replacing chars in a property

/*
Hi folks!

I have a property which contains a path "C:\Documents and Settings 
\..." and I have to convert it to this format "c/Documents\ and\  
Settings/...". Thus I have to replace "\" with "/" and so on.

How do I do this? I can access my property with ${myProperty} and  
want to get another property with the replaced chars.
*/

<project name="bla" default="main">

  <property name="myproperty" value="C:\Documents and Settings\"/>

  <target name="depends">
   <script language="ruby">
   <![CDATA[
    $project.setProperty "foobar", $myproperty.gsub(/\\/,'/')
   ]]>
   </script>
  </target>

<target name="main" depends="depends">
 <echo>$${foobar} == ${foobar}</echo>
</target>
</project>


main:
     [echo] ${foobar} == C:/Documents and Settings/
BUILD SUCCESSFUL
Total time: 1 second


Regards, Gilbert

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


Mime
View raw message