ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: 2nd try: Creating property using regular expression on string/property value
Date Wed, 19 Feb 2003 13:12:54 GMT
You can't change the values of properties because they're immutable.

But you could create a second property based on the value of your string by:
1) creating a property file
2) using regular expression to change the value in the property file.
3) source the properties

Some example ..

    <target name="foo.default"
            description="create newchangestring from string1">
        <!-- 1) create a property file. -->
        <property name="string1" value="tom dick"/>
        <echo message="changestring=${string1}"/>
        <propertyfile file="">
            <entry key="changestring" value="${string1}"/>
        <!-- 2) change the value in the property file. -->
        <replaceregexp file=""
            replace="newchangestring=\1\ and\ harry"/>
        <!-- 3) source the properties -->
        <property file=""/>
        <echo message="newchangestring=${newchangestring}"/>


     [echo] changestring=tom dick
[propertyfile] Updating property file: /temp/
     [echo] newchangestring=tom dick and harry



> -----Original Message-----
> From: Tony Obermeit []
> Sent: 19 February 2003 12:36
> To:
> Subject: 2nd try: Creating property using regular expression on
> string/property value
> I'm still trying to find an answer for this question.  I've 
> searched the 
> documentation on regexp which appears to apply to mapping or 
> selecting 
> filenames based on a regular expression.  I just want to do a string 
> replace on a property value using a regular expression.  Any other 
> ideas?  Just point me to the appropriate ant documentation.
> thanks
> Tony
> >Date: Mon, 17 Feb 2003 07:02:34 +1000
> >To:
> >From: Tony Obermeit <>
> >Subject: Creating property using regular expression on 
> string/property value
> >
> >I have a property value that I want to use for part of a 
> file name but the 
> >property value sometimes includes spaces that I don't want 
> to include in 
> >the filename.  I am looking to create a new property value 
> but apply a 
> >regular expression to an existing property value when I 
> create it.  The 
> >examples I've seen seem to do this with replacing tokens within an 
> >existing file, I want to do it effectively within a string 
> in my build script.
> >
> >Thanks
> >
> >Tony
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:


For more information on HBOS Treasury Services, please visit

Or for details of our online FX & Deposit services, please go to

HBOS Treasury Services plc is part of the HBOS Group, which also includes Halifax plc and
Bank of Scotland.
Registered Office: 33 Old Broad Street, London EC2N 1HZ. Registered No. 2692890. Registered
in England.
Regulated by the Financial Services Authority.

The information contained in this message is confidential and is intended for the addressee
only. If you have received this message in error or there are any problems please notify the
originator immediately. The unauthorised use, disclosure, copying or alteration of this message
is strictly forbidden. This mail and any attachments have been scanned for viruses prior to
leaving the HBOS Treasury Services plc network. HBOS Treasury Services plc will not be liable
for direct, special, indirect or consequential damages arising from alteration of the contents
of this message by a third party or as a result of any virus being passed on.

HBOS Treasury Services plc reserves the right to monitor and record e-mail messages sent to
and from this address for the purposes of investigating or detecting any unauthorised use
of its system and ensuring its effective operation.


View raw message