GNU bug report logs - #21865
Parenthesis subexpressions

Previous Next

Package: grep;

Reported by: Valerio Bozzolan <bozzolan.valerio <at> educ.di.unito.it>

Date: Sun, 8 Nov 2015 21:58:02 UTC

Severity: wishlist

Full log


Message #14 received at 21865 <at> debbugs.gnu.org (full text, mbox):

From: Valerio Bozzolan <bozzolan.valerio <at> educ.di.unito.it>
Cc: 21865 <at> debbugs.gnu.org
Subject: Re: bug#21865: Parenthesis subexpressions
Date: Mon, 09 Nov 2015 17:03:39 +0100
[Message part 1 (text/plain, inline)]
Thanks for agreeing with the evolution of the meaning of "-o".

Just to make you a laugh: I was reproducing egrep with $BASH_REMATCH:
https://gist.github.com/valerio-bozzolan/6787675e931dce1ba7e9

Definitely not beautiful... but really effective for me.

So something like "egrep -o $n regex" also can save the world from code similar to mine.

On 9 November 2015 14:50:46 CET, Stephane Chazelas <stephane.chazelas <at> gmail.com> wrote:
>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

-- 
Valerio Bozzolan
Email sent from Android (CyanogenMod) using K-9 Mail.
[Message part 2 (text/html, inline)]

This bug report was last modified 9 years and 170 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.