You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Nicolai Kamenzky <ka...@inf.fu-berlin.de> on 2007/11/14 16:43:04 UTC
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.
Cheers,
Nicolai
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: Replacing chars in a property
Posted by "Rebhan, Gilbert" <Gi...@huk-coburg.de>.
-----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