ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <peter.rei...@corvil.com>
Subject Re: Remove a specific line from a file.
Date Wed, 12 Nov 2003 08:56:13 GMT
On Wednesday 12 November 2003 07:22, Stefan Bodewig wrote:
> On Tue, 11 Nov 2003, Robert Priest <Robert.Priest@bentley.com> wrote:
> > Can anyone tell me how to remove a specific line from a text file
> > using ant.
>
> <replaceregexp> would probably work - simply replace the line your
> don't want to see with nothing.
>
> Ant 1.6beta with a <linecontainsregexp> filterreader in <copy> would
> work as well - you'd jave to craft a regexp that matched all your
> lines except for the one you don't want to see in your file.

Ant 1.6beta also has a <scriptfilter> which allows you to write
a filter as follows:
    <concat>
      This is a line
      this is a bad line
      This is a good line
      <filterchain>
        <scriptfilter language="beanshell">
          if (self.getToken().indexOf("good") == -1) {
             self.setToken(null);
          }
        </scriptfilter>
      </filterchain>
    </concat>

With java 1.4 one may use a regex:

        <scriptfilter language="beanshell">
          if (!self.getToken().matches(".*This.*good.*line.*")) {
              self.setToken(null);
          }
        </scriptfilter>

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