buggrep - Bugs: bug #24732, --only-matching prints only...


You are not allowed to post comments on this tracker with your current authentication level.

bug #24732: --only-matching prints only non-overlapping matches in each line

Submitted by:  Jeffrey Milloy <jmilloy>
Submitted on:  Sun 02 Nov 2008 07:35:25 PM UTC  
Votes:  5  
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Sat 21 Sep 2013 05:52:40 AM UTC, comment #3: 

This is a nonissue. You see, in your example the second 0 IS matched by the third period. However, that being said, i do think regular expressions should have a syntax to provide a context for a match while excluding it. But it would have to be more explicit than just using a nonexplicit identifier in the match pattern. I guess you could create a command that would take 3 regular expressions as input.
Another thing about regular expression would be to make them nongreedy by default. Maybe take a look at cgrep.

jikszzve <jikszzve>
Sat 06 Feb 2010 01:30:49 PM UTC, comment #2: 

maybe leave open, but as a feature reqest.  However, with ambiguity like this, it's good to document (and add a test case demonstrating) the intended behavior.

Does any other implementation of grep offer this option?

Jim Meyering <meyering>
Project Administrator
Sat 06 Feb 2010 01:15:39 PM UTC, comment #1: 

This is by design, there could be n^2 overlapping matches.  Unless I misunderstand I'm inclined to close this.  Any other opinions?

Paolo Bonzini <bonzini>
Sun 02 Nov 2008 07:35:25 PM UTC, original submission:  

Maybe this is more of a feature request, but as I understand the option, --only-matching should print all matches to the pattern in each line.

for example:

$ echo 'abcd00efghi' | grep -o ..0..

# what I expect:
# $ echo 'abcd00efghi' | grep -o ..0..
# cd00e
# d00ef

note that more than one match in a line will be printed, if they do not overlap:

$ echo 'ab0cdefg0hi' | grep -o ..0..

Was the option meant to work this way?

Jeffrey Milloy <jmilloy>


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by matthewrussell (Voted in favor of this item)
  • -email is unavailable- added by meyering (Posted a comment)
  • -email is unavailable- added by bonzini (Posted a comment)
  • -email is unavailable- added by jmilloy (Submitted the item)
  • -email is unavailable- added by jmilloy

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 5 encouragements so far.

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-01-14 matthewrussell Carbon-Copy- => Added matthewrussell
    2008-11-02 jmilloy Carbon-Copy- => Added jmilloy

    Back to the top

    Powered by Savane 3.7