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: (newbie) how insert content of one file into middle of anothe r one
Date Fri, 18 Jul 2003 12:33:51 GMT
> Subject: Re: (newbie) how insert content of one file into middle of
> another one
> 
> 
> --- Antoine Levy-Lambert <anantoinenantbuildom> wrote:
> > Hi Monika,
> > I would recommend that you download ant1.6alpha.
> > In this version, there are some <heheadfilterand <tatailfilterwhich
> > can be
> > used inside <fifilterchainwhich itself can be nested into <copy/> or
> > <move/>
> > Here an example in the doc of ant 1.6
> > 
> > <loloadfilersrcfile${srsrcile}" property="${srsrcile.head}">
> >   <fifilterchain
> >     <heheadfilterines="15"/>
> >   </fifilterchain
> > </loloadfile
> > This stores the first 15 lines, skipping the first 2 lines, of the
> > supplied
> > data in the poporperty{srsrcile.head}. (Means: lines 3-17)
> > 
> > You might need to do your work in several step, but it should be
> > possible,
> > especially if you always need the 2 first lines of file a, then file
> > b, then
> > the last line of file a.
> > 
> > Antoine
> > 
> > 
> 
> Unfortunately I can't use line number count to find the insertion
> position in the first file. I have a certain string in this file which
> is my marker where the insertion should occur.



Maybe <replaceregexp> could do the job.
http://ant.apache.org/manual/OptionalTasks/replaceregexp.html

Something like

<loadfile property="text" srcFile="insertedText"/>
<replaceregexp
    file="theFile"
    match="(.*)(textafterthis)(.*)"
    replace="\1\2$text\3"
/>
    


Jan

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