On Wednesday 12 November 2003 07:22, Stefan Bodewig wrote:
> On Tue, 11 Nov 2003, Robert Priest <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to