You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Michael Sorens <ms...@myrealbox.com> on 2006/09/15 17:40:59 UTC

regexp recognition over a group of files

I am looking to do a task that is simple with the unix find command, but I cannot quite seem to grok all the pieces in ant to do it: I want to generate a list of files where the contents of each file contain--or do not contain, at my option--a particular string matching a regular expression. I would simply like to print a list of the resulting filenames on the console. Any suggestions?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: regexp recognition over a group of files

Posted by Matt Benson <gu...@yahoo.com>.
In Ant 1.6.5:

<property name="re.example" value="foo +.* +bar" />

<pathconvert property="matched">
  <path>
    <fileset dir="lookhere">
      <containsregexp expression="${re.example}" />
    </fileset>
  </path>
</pathconvert>
<echo>$${matched}=${matched}

In Ant 1.7 (please test our betas) you can simplify
the pathconvert/echo:

<pathconvert>
  <fileset dir="lookhere">
    <containsregexp expression="${re.example}" />
  </fileset>
</pathconvert>

-i.e., pathconvert w/o a property sends result to the
log; note also that the fileset can be specified
directly rather than having to be nested into a path.

HTH,
Matt

--- Michael Sorens <ms...@myrealbox.com> wrote:

> I am looking to do a task that is simple with the
> unix find command, but I cannot quite seem to grok
> all the pieces in ant to do it: I want to generate a
> list of files where the contents of each file
> contain--or do not contain, at my option--a
> particular string matching a regular expression. I
> would simply like to print a list of the resulting
> filenames on the console. Any suggestions?
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org