repetition operator +

View: New views
2 Messages — Rating Filter:   Alert me  

repetition operator +

by robslang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Shouldn't "a\n" match the regular expression a+ in the following case?

$ echo a | grep 'a'
a
$ echo a | grep 'a*'
a
$ echo a | grep 'a+'
$

--Robert



Re: repetition operator +

by Matthew Wakeling :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 3 Jul 2009, robslang@... wrote:
> Shouldn't "a\n" match the regular expression a+ in the following case?
>
> $ echo a | grep 'a'
> a
> $ echo a | grep 'a*'
> a
> $ echo a | grep 'a+'
> $

See the section "Basic vs Extended Regular Expressions" in the grep man
page.

$ echo a | grep "a\+"
a
$ echo a | grep -E "a+"
a


Matthew

--
 Doctor:  Are you okay? You appear to be injured.
 Neelix:  Aaaaaaah!
 Doctor:  It's okay, it looks superficial.
 Neelix:  Am I going to die?
 Doctor:  Not unless you are allergic to tomatoes. This appears to be a sauce
          some kind.