ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: replacing commented text
Date Wed, 17 Dec 2003 07:13:00 GMT
I tried a little bit. But I haven´t found a solution for the first '#######'
line quickly.
But you can try


    <copy file="in.txt" tofile="out.txt"/>
    <replaceregexp file="out.txt"
        match=".*(#environnement B.*End of environnement B).*"
        replace="\1"
        flags="gs"
    />                  


Flags:
  g   You have to work with the whole file to have the start-LINE and
end-LINE in ONE
      regexp.
  s   Don´t worry about number of lines ...

Replace
  \1  All which is matched in the first bracket section in 'match'

Match
  .*     Ignore all before the start string
  (      Start collecting text
  #en..  The startstring
  .*     collect all
  ..B    End string
  )      End collecting text
  .*     Ignore the rest



Jan




> -----Original Message-----
> From: momo momo [mailto:molbiatch@hotmail.com]
> Sent: Tuesday, December 16, 2003 4:58 PM
> To: user@ant.apache.org
> Subject: replacing commented text
> 
> 
> Hi all,
> I would like to extract a piece of my  property file:
> 
> ##################################################
> #environnement A
> ##################################################
> #Jdbc
> #project.jdbc.datasource=datasource1
> [...]
> #End of environnement A
> 
> ##################################################
> #environnement B
> ##################################################
> #Jdbc
> project.jdbc.datasource=datasource2
> [...]
> #End of environnement B
> 
> 
> and copy it in another file to have that:
> 
> ##################################################
> #environnement A
> ##################################################
> #Jdbc
> project.jdbc.datasource=datasource1
> [...]
> #End of environnement A
> 
> I don't know what is exatly in the sample, the only thing I 
> know is the 
> first 3 lines and the last line.
> I tried to catch the text sample that interest me by using copy and 
> filterchain
> 
> <copy file="${src}" tofile="${dest}">
> 	<filterchain>
> 		<filterreader 
> classname="org.apache.tools.ant.filters.LineContainsRegExp">
> 			<param type="regexp" value="??????????????"/>
> 		</filterreader>
> 	</filterchain>
> </copy>
> 
> but I didn't succeed!
> Is that possible to take a piece of text and copy it in a file?
> any help will be appreciate.
> 
> Momo
> 
> _________________________________________________________________
> Hotmail : un compte GRATUIT qui vous suit partout et tout le temps ! 
> http://g.msn.fr/FR1000/9493
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message