On Tue Mar 21 09:19:47 2006, PETEK wrote:
Show quoted text> (Carryover from prior RT; created by alester on Fri Nov 22 11:13:28 2002)
>
> Sometimes you want to be able to search for multiple patterns in a file,
> and see when they coexist. Support this functionality like:
>
> ack foo --and bar filenames
ack 'foo.*bar' filenames
Show quoted text> ack foo --or bar filenames
ack 'foo|bar' filenames
That's at least the solution that 'grep' provides.
I can see that "--and" and "--or" would be useful for people who don't
already know regular expressions.
However, adding these begs the application to deal with grouping of
various AND and OR combinations, which seems like a pain.
My recommendation: A doc patch. When people check the docs for for 'and'
and 'or' options, they find simple examples that solve the problem with
regex'es.
=head1 Advanced Searches
=head2 Match all terms in a file.
Use C<.*?> to specify a minimal number of any characters between to
terms, matching both terms in the file:
ack 'foo.*?bar' filenames
=head2 Matching any terms in a file
Use C<|> to specify one match I<OR> another
ack 'foo|bar' filenames
=cut
Of course, if the matching is really line-based and not file-based, the
docs will need to be adjusted slightly.
Mark