bug-grep
[Top][All Lists]
Advanced

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

bug#21865: Parenthesis subexpressions


From: Stephane Chazelas
Subject: bug#21865: Parenthesis subexpressions
Date: Mon, 9 Nov 2015 13:50:46 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

2015-11-08 21:49:03 +0100, Valerio Bozzolan:
> Sorry... typo...
> 
>     echo abcde | grep -o -E 'b([a-z])d'
>     => "bcd"
> 
> Can't I choose to have only "c"?
[...]

That's correct, GNU grep doesn't have that capability (yet).
Recent versions of pcregrep do:

$ echo abc | pcregrep -o1 '.(.).'
b

Now, I'm not a GNU grep maintainer but I suppose the question is
how far do we want to take grep away from its original purpose
(print the lines that match a pattern which is what g/re/p
stands for).

GNU grep is already doing find's job with -r, part of sed's job
with -o/--colour.

Having said that, I do agree it's the logical continuation after
-o.

Note that for now, you can already do:

$ echo abcde | grep -o -P 'b\K[a-z](?=d)'
c


-- 
Stephane





reply via email to

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