bug-grep
[Top][All Lists]
Advanced

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

Re: plus sign appears not to work as expected


From: Bob Proulx
Subject: Re: plus sign appears not to work as expected
Date: Tue, 14 Feb 2012 15:27:39 -0700
User-agent: Mutt/1.5.18 (2008-05-17)

Bill Gradwohl wrote:
> address@hidden wrote:
> > For grep, you need '^[[:alpha:]]\+'.
>
> That backslash did it.
> 
> Now I'm going into the docs to find where it says I need a backslash for
> the + but nothing for the *.

It starts with this part:

    grep understands two different versions of regular expression syntax:
    "basic" and "extended."  In GNU grep, there is no difference in
    available functionality using either syntax.  In other implementations,
    basic regular expressions are less powerful.  The following description
    applies to extended regular expressions; differences for basic regular
    expressions are summarized afterwards.

'grep' handles basic regular expressions.  'egrep' is the old name for
'grep -E' and it handles extended regular expressions.  * is a basic
regular expression and + is an extended regular expression.

GNU grep handles both in a compatible way.  If you call 'grep' then it
handles the basic regular expressions like * and also the extended
expressions if the extended one is escaped.

If you call it with 'grep' then you should use the basic syntax.  But
the extended is available if it is escaped.

  grep    '^[[:alpha:]]\+'

If you call it with -E then you get the full extended syntax.

  grep -E '^[[:alpha:]]+'

Bob



reply via email to

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