ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Inger <ma...@sedonacorp.com>
Subject Re: AW: search for words in a file
Date Thu, 18 Oct 2001 14:39:44 GMT
a will back, i submitted a ReplaceRegExp task for
consideration into the optional package.  i'm not
sure whatever became of it, but the underlying data
types might be very useful to you in your search
task:


// There may be typos in this code, as i just
// whipped it up in this e-mail.

import org.apache.tools.ant.util.regexp.RegexpFactory;
import org.apache.tools.ant.util.regexp.Regexp;

public class MyTask extends Task
{
  public void execute()
   throws BuildException
  {
    // factory class instantiates the apprioriate
    // implementation of the Regexp interface
    RegexpFactory factory = new RegexpFactory();
    Regexp re = factory.newRegexp();
    re.setPattern(pattern);
    if (re.matches(input))
    {
      // do something
    }
  }
}

you can use one of 3 regular expression packages.
The value of the system property "ant.regexp.regexpimpl"
determines which package to use:

Jakarta-Oro (default) : 
   org.apache.tools.ant.util.regexp.JakartaOroRegexp

Jakarta-Regexp
   org.apache.tools.ant.util.regexp.JakartaRegexpRegexp

Jdk1.4-Regexp
   org.apache.tools.ant.util.regexp.Java14RegexpRegexp


I have attached this task, and the underlying classes
you would need to use in your task, should you go that
route.

On Thu, 2001-10-18 at 10:11, thomas.kerle@pd.admin.ch wrote:
> Well,
> 
> What I propose is really not for beginners. Make your own task (take the
> documented example SimpleTask.java) and make a simple search routine. You
> have to set up three main attributes: The root path, the specific word and a
> text file to save the results in. OroMatcher would be easier to use. Try it!
> In the patternset you can add includesFile to include the file in a fileset.
> Have a look at the attachment to make your own task...
> 
> 
> It's used like this:
> SearchTask d:\root d:\root\matches.txt someIdentifier 
> 
> 
> Thomas Kerle
>  
> Informatikdienste
> 
> -----Urspr√ľngliche Nachricht-----
> Von: Christine.Woon@nurun.com [mailto:Christine.Woon@nurun.com] 
> Gesendet: Mittwoch, 17. Oktober 2001 15:31
> An: ant-user@jakarta.apache.org
> Betreff: search for words in a file
> 
> Hi guys,
> 
> I am new at Ant, and was curious if there is any task to search for a
> specific word i.e 'main' in a file.
> If the word doesn't exist then include it in a fileset, otherwise ignore
> it.
> 
> Thank you
> 
> -Christine
> 
-- 
Matt Inger (matt.inger@sedonacorp.com)
Sedona Corporation
455 S. Gulph Road, Suite 300
King of Prussia, PA 19406
(484) 679-2213
"Self-respect - the secure feeling that no one,
 as yet, is suspicious." -H.L. Mencken 

Mime
View raw message