ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject RE: Extract property out of multiline file
Date Thu, 09 Dec 2004 08:41:33 GMT

Hi, 

The given txtfile looks like that f.e. :

Env1,
Env2,
Env3,

Now i have :

<loadfile
      property="targets"
      srcFile="K:\test\targets.txt">
  <filterchain>
    <tokenfilter>
      <filetokenizer/>
      <replaceregex pattern="${line.separator}"
                    flags="g"
                    replace=" "/>  
    </tokenfilter>
    <deletecharacters chars=","/>
  </filterchain> 
</loadfile>

So now echo message="${targets}" gives me :

Env1 Env2 Env3

Thanks to the list for all the helpful hints - you made my day :)

Gilbert


-----Original Message-----
From: Erskine, Chris [mailto:chris.erskine@eds.com]
Sent: Wednesday, December 08, 2004 3:03 PM
To: Ant Users List
Subject: RE: Extract property out of multiline file


Since you already have the , in the line, you do not want to replace the
line.separator with a new comma.  Change the replace to replace="" and you
will not be adding the extra comma.

To get rid of the last comma, I would try something like another pass
through the file replacing the comma at the end of the line with just a
file.separator.  The pattern would be something like ",$".

Chris Erskine
 
EDS Consulting Services
F5-EDS-001
2424 Garden of the Gods Rd
Colorado Springs, CO  80919
 
Phone: 719-535-6064

> -----Original Message-----
> From: Rebhan, Gilbert [mailto:Gilbert.Rebhan@huk-coburg.de]
> Sent: Wednesday, December 08, 2004 6:47 AM
> To: Ant Users List
> Subject: RE: Extract property out of multiline file
> 
> 
> Hi, thanks for the tip, nearly perfect.
> 
> With
> 
> Env1,
> Env2,
> 
> and
> <replaceregex pattern="${line.separator}"
>                     flags="g"
>                     replace=","/>
> 
> it gives me -> Env1,,Env2,,
> 
> without  flags="g"
> 
> it gives me -> Env1,,Env2,
> 
> The second ',' between the Env's and the last ',' after Env2 shouldn't
> appear.
> then it would be perfect.
> 
> Any hints ?
> 
> Regards, Gilbert
> 
> 
> -----Original Message-----
> From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
> Sent: Wednesday, December 08, 2004 2:31 PM
> To: user@ant.apache.org
> Subject: AW: Extract property out of multiline file
> 
> 
> Just a thought ...
> 
> <loadfile>
>   <filterchain>
>     <tokenfilter>
>       <filetokenizer/>
>       <replaceregex pattern="${line.separator}"
>                     flags="g"
>                     replace=","/>
>     </tokenfilter>
>   </filterchain>
> </loadfile>
> 
> 
> Jan
> 
> > -----Urspr√ľngliche Nachricht-----
> > Von: Rebhan, Gilbert [mailto:Gilbert.Rebhan@huk-coburg.de]
> > Gesendet am: Mittwoch, 8. Dezember 2004 14:21
> > An: ant_user (E-Mail)
> > Betreff: Extract property out of multiline file
> >
> >
> > Hi, i have a txtfile generated by a script.
> >
> > The file looks like that :
> >
> > Env1,
> > Env2,
> > Env3,
> >
> > sometimes there's only one value in that file, sometimes
> > more, like above.
> >
> > I want to stript the ',' and get that Env's into one property :
> >
> > myproperty = "Env1,Env2,Env3"
> >
> > How to do that without scripting ?
> >
> > Thanks for any hints!!
> >
> > Regards, 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

---------------------------------------------------------------------
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