You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Lasher, James L" <ji...@hp.com> on 2005/10/11 01:43:18 UTC
splitting a string
Hello all,
I'm hoping someone here could help me with an idea on how to take a
property and "split" it into two (additional) properties. My specific
situation is that I have a property that has a value of
[0-9][0-9].[0-9][0-9].[0-9][0-9][0-9]. I would like to split this so
that I end up with one new property whose value is the beginning of the
original property string ([0-9][0-9].[0-9][0-9]) and the second whose
value would be the last set of [0-9][0-9][0-9].
I currently have the original property defined in a file
(/tmp/refverprops) which looks like:
ReferenceVersionMinor=02.10.555
I've figured out a way to get the second property value which in my
example will be ReferenceVersionMinor by doing the following:
<loadproperties srcfile="/tmp/refverprops">
<filterchain>
<linecontains>
<contains value="ReferenceVersionMinor"/>
</linecontains>
<tokenfilter>
<replaceregex pattern="[0-9][0-9]\.[0-9][0-9]\." replace=""/>
</tokenfilter>
</filterchain>
This will give me a property name/value of ReferenceVersionMinor/555
I can't figure out though how to do something similar to get the first
property value of: 02.10 (without a trailing dot after 10). I could
whip up a custom task to do this for me, but would prefer to use what's
already available in Ant, if I can find what that might be. Can anyone
help?
-jim-
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: splitting a string
Posted by Jeffrey E Care <ca...@us.ibm.com>.
I think AntContrib's <propertyregex> task could do this.
--
Jeffrey E. Care (carej@us.ibm.com)
WebSphere v7 Release Engineer
WebSphere Build Tooling Lead (Project Mantis)
"Lasher, James L" <ji...@hp.com>
10/10/2005 07:43 PM
Please respond to
"Ant Users List"
To
"Ant Users List" <us...@ant.apache.org>
cc
Subject
splitting a string
Hello all,
I'm hoping someone here could help me with an idea on how to take a
property and "split" it into two (additional) properties. My specific
situation is that I have a property that has a value of
[0-9][0-9].[0-9][0-9].[0-9][0-9][0-9]. I would like to split this so
that I end up with one new property whose value is the beginning of the
original property string ([0-9][0-9].[0-9][0-9]) and the second whose
value would be the last set of [0-9][0-9][0-9].
I currently have the original property defined in a file
(/tmp/refverprops) which looks like:
ReferenceVersionMinor=02.10.555
I've figured out a way to get the second property value which in my
example will be ReferenceVersionMinor by doing the following:
<loadproperties srcfile="/tmp/refverprops">
<filterchain>
<linecontains>
<contains value="ReferenceVersionMinor"/>
</linecontains>
<tokenfilter>
<replaceregex pattern="[0-9][0-9]\.[0-9][0-9]\." replace=""/>
</tokenfilter>
</filterchain>
This will give me a property name/value of ReferenceVersionMinor/555
I can't figure out though how to do something similar to get the first
property value of: 02.10 (without a trailing dot after 10). I could
whip up a custom task to do this for me, but would prefer to use what's
already available in Ant, if I can find what that might be. Can anyone
help?
-jim-
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org