ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neil Benn <neil.b...@gmail.com>
Subject Re: ReplaceRegExp with windows filenames
Date Thu, 25 Aug 2005 19:54:58 GMT
Hello,

         Thanks for the responses Gilbert and Andrew, a concise
description of the issue I have is that I have a section such as :

1 = ,"DropPaqEtc",,"C:\Documents and Settings\Neil Benn\My
Documents\svnfiles\trunk\DropPaq\installer\CE"   ; The etc directory
which contains all image and the jar file

    I want to replace the section of the path up to DropPaq with
${basedir}.  Doing a ReplaceRegEx outputs data with the backslashes
not present in the output (both one backslash and two back slashes -
as shown later on).

    Therefore I tried loading a property from the file and using the
propertyregex and echoing that to the screen (and echoing to a file -
same thing happens):

  <target name="replace_inf_paths" depends="init">
    <loadfile srcFile="${basedir}/installer/CE/DropPaq.inf" 
	          property="inf_contents"/>
    
	<propertyregex property="basedir.escaped" input="${basedir}" regexp="\\"
		replace="\\\\\\\\" global="true"/>
    <propertyregex property="inf_contents.escaped" input="${inf_contents}" 
	               regexp="C\:\\.*\\DropPaq" replace="${basedir.escaped}"
global="true"/>
	<echo message="${inf_contents}"/>
	<echo message="----------------------------------------------------------"/>
                    <echo
message="----------------------------------------------------------"/>
	<echo message="${inf_contents.escaped}"/>
	<echo message="${basedir.escaped}"/>
  </target>

    So, it seems if I use ReplaceRegEx on the file or load the file
into a property and if I use one or two backslashes in the, I get out
something like this (either from an echo or in the file:

     [echo] 1 = ,"DropPaqEtc",,"C:Documents and SettingsNeil BennMy
Documentssvn_timtrunkDropPaq\installer\CE"   ; The etc directory which
contains all image and the jar file

    I then tried to escape the : char with an extra backslash as follows:

  <target name="replace_inf_paths" depends="init">
    <loadfile srcFile="${basedir}/installer/CE/DropPaq.inf" 
	          property="inf_contents"/>
    
	<propertyregex property="basedir.escaped" input="${basedir}" regexp="\\"
		replace="\\\\\\\\" global="true"/>
	<propertyregex property="basedir.escaped2" input="${basedir.escaped}"
regexp="\:"
		replace="\\\\:" global="true"/>
    <propertyregex property="inf_contents.escaped" input="${inf_contents}" 
	               regexp="C\:\\.*\\DropPaq"
replace="${basedir.escaped2}" global="true"/>
	<echo message="${inf_contents}"/>
	<echo message="----------------------------------------------------------"/>
	<echo message="${inf_contents.escaped}"/>
	<echo message="${basedir.escaped2}"/>
  </target>

    Same thing as before except the output for basedir.esacpared2 is now:

     [echo] C\:\\Documents and Settings\\Neil Benn\\My
Documents\\svn_tim\\trunk\\DropPaq

  But the value of inf_contents.escaped is still the same!

    To tell you the truth - I'm completly stumped here - does anyone
have any idea as to what could be going on - it just seems bizzare!

    Pizza is offered in exchange for help (I've got a 36cm one sat
next to me!!) - will post to anywhere in the world ;-).

Cheers,

Neil

On 8/25/05, Rebhan, Gilbert <Gilbert.Rebhan@huk-coburg.de> wrote:
> 
> Hi,
> 
> 
> -----Original Message-----
> From: Neil Benn [mailto:neil.benn@gmail.com]
> Sent: Wednesday, August 24, 2005 11:19 PM
> To: Ant Users List
> Subject: Re: ReplaceRegExp with windows filenames
> 
> 
> /*
>         Thanks for the tip - however it still does the same thing -
> it seems like the backslashes are simply being ignored (if there is
> one or two).  I'll make some further investigations - if anyone has
> ideas as to what could be going on here - I;d appreciate any pointers.
> */
> 
> Didn't follow the thread, but maybe you can use a filterchain after
> replaceregex =
> 
> <loadfile property="foo" srcfile="C:/path/to/myfile.txt">
> <tokenfilter>
>    <replaceregex ... "/>
> </tokenfilter>
> <filterchain>
>         <replacestring from="\" to="//" />
>        </filterchain>
> </loadfile>
> 
> 
> /*
> However I can;t find a task to write a
> property into a file (ant property write {of variation thereof} -
> gives back the wrong things) - does anyone know of one?
> */
> 
> maybe =
> 
> <echo file="foobar.txt" append="true|false">${myproperty}</echo>   ?!
> 
> best to write <echo ...> ... </echo> all on one line and starting
> at beginning of the line, because otherwise unwanted blanks appear
> in your file.
> 
> Gilbert
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
>

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


Mime
View raw message