You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Henrik Gemal <sp...@mail.dk> on 2005/06/04 10:58:05 UTC

stripping chars from property

I have the following:
<property file="ext.version" value="4.0.0" />

Now I need to create a file with the version in it's name but without 
the . (dots) something like:
blabla400.zip

So is there a way to convert the ${ext.version} into a new property 
without the dots?

I need this to be a generic way since I'm using the build.xml file in 
different places


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


Re: stripping chars from property

Posted by Ivan Ivanov <ra...@yahoo.com>.
Hello Henrik,

Here is one way to do this using ant-contrib[1] and
its task <propertyregex>[2]:

<project>
  <taskdef
  resource="net/sf/antcontrib/antcontrib.properties"/>
  <property name="ext.version" value="4.0.0"/>
  <propertyregex property="ext.version.undotted"
    input="${ext.version}"
    regexp="\." replace=""/>
  <echo>$${ext.version.undotted} is
${ext.version.undotted}</echo>
</project>

The output of this build file is:
[echo] ${ext.version.undotted} is 400.

There are also other ways to do it, like using
<scriptdef> and a scripting language like javascript
to do the string manipulation, but I think the one
above is the easiest.

HTH Ivan

[1] http://ant-contrib.sourceforge.net/
[2]http://ant-contrib.sourceforge.net/tasks/tasks/propertyregex.html

--- Henrik Gemal <sp...@mail.dk> wrote:

> I have the following:
> <property file="ext.version" value="4.0.0" />
> 
> Now I need to create a file with the version in it's
> name but without 
> the . (dots) something like:
> blabla400.zip
> 
> So is there a way to convert the ${ext.version} into
> a new property 
> without the dots?
> 
> I need this to be a generic way since I'm using the
> build.xml file in 
> different places
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



		
__________________________________ 
Discover Yahoo! 
Find restaurants, movies, travel and more fun for the weekend. Check it out! 
http://discover.yahoo.com/weekend.html 


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