ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Obermeit <ton...@compuserve.com>
Subject RE: 2nd try: Creating property using regular expression on string/property value
Date Wed, 19 Feb 2003 20:11:54 GMT
Thanks, I think this will work for me.  I always intended to create a new 
property, it would be nice to be able to do this without creating any 
external files, conceptually my property is just like another string 
variable that I want to copy into a different variable name and do some 
translations along the way.  Thanks again for your help.

Enjoy your day!

Tony

At 01:12 PM 19/02/2003 +0000, you wrote:
>
>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="temp.properties">
>             <entry key="changestring" value="${string1}"/>
>         </propertyfile>
>         <!-- 2) change the value in the property file. -->
>         <replaceregexp file="temp.properties"
>             match="changestring=(.*)"
>             replace="newchangestring=\1\ and\ harry"/>
>         <!-- 3) source the properties -->
>         <property file="temp.properties"/>
>         <echo message="newchangestring=${newchangestring}"/>
>     </target>
>
>
>output..
>
>foo.default:
>      [echo] changestring=tom dick
>[propertyfile] Updating property file: /temp/temp.properties
>      [echo] newchangestring=tom dick and harry
>
>HTH
>
>Simon
>
> > -----Original Message-----
> > From: Tony Obermeit [mailto:tonyob@compuserve.com]
> > Sent: 19 February 2003 12:36
> > To: ant-user@jakarta.apache.org
> > 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: ant-user@jakarta.apache.org
> > >From: Tony Obermeit <tonyob@compuserve.com>
> > >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: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> >
>
>--
>
>------------------------------------------------------------------------------
>For more information on HBOS Treasury Services, please visit 
>http://www.HBOSTS.com
>
>Or for details of our online FX & Deposit services, please go to 
>http://www.HBOSdeal.com
>
>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.
>
>==============================================================================
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org




Mime
View raw message