Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the ack CPAN distribution.

Maintainer(s)' notes

ack's issues are tracked at https://github.com/petdance/ack2

Report information
The Basics
Id: 18269
Status: resolved
Priority: 0/
Queue: ack

People
Owner: Nobody in particular
Requestors: PETEK [...] cpan.org (weekly)
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Add multiple regex support to ack
(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 --or bar filenames
From: MARKSTOS [...] cpan.org
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