bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪


From: Paul Eggert
Subject: bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union)
Date: Wed, 16 Oct 2019 11:57:31 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

Wouldn't it be more useful to have an intersection operator in regular expressions? That is, the pattern 'A\&B' would match anything that is matched by both A and B. If A and B have parenthesized subexpressions, both sets of parentheses would match and would count.

Assuming concatenation has higher precedence than \&, the requested behavior could be achieved via:

  grep '.*X.*\&.*Y.*\&.*Z.*'

This approach would allow intersection to be nested inside other operations. Also, it would clarify how other features work. For example, grep -o has clear semantics with this approach, whereas the semantics of grep -o are not so clear with the proposed --and option.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]