[Top][All Lists]

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

[bug-grep] Re: grep bug?

From: Stepan Kasal
Subject: [bug-grep] Re: grep bug?
Date: Tue, 15 Mar 2005 16:52:19 +0100
User-agent: Mutt/1.4.1i

        thank you for the bug report.

[A new list was created to discuss grep bugs, please direct futher discussion
to address@hidden

> >     echo " abc"|egrep -o "[a-z]*"
> >     result: none

indeed, this is a bug, grep should print the string "abc", probably
preceeded by an empty line.

> It matches the empty string before the space.

This explains the internal reason for the bug, but it does nothing with
the fact that this is a bug.

But Andreas is right:
As a general rule, don't use grep with a regex which can match an empty
string.  There is a big danger that the result won't be what you meant.

In your example, use
        echo " abc" | egrep -o "[a-z]+"

Have a nice day,
        Stepan Kasal

reply via email to

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