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