Simple Regular Expression Question
OK - I'm new to UNIX and reg. ex, so this is probably very basic, but I can't figure it out. Given a simple text file called namelist with a list of names such as
John Doe
Bob Cat
Billy Bob
Joe Mama
etc,
the command:
grep '[A-Z][a-z]*' namelist
yields all lines, as it should, an upper case letter followed by 0 or more lower case letters.
yet
grep '[A-Z][a-z]+' namelist
yields nothing. Every line starts with one upper case letter followed by one or more lower case, but this yields nothing.
Also
grep '[A-Z][a-z]\{1,\}' namelist
yields every name on the list. I've found a couple of references that say this is identical to the 2nd grep command above (one ore more lower case letters), yet this lists the names, as I would expect, but the [a-z]+ syntax does not.
Can someone explain this to me?
Thank You,
Doug
OK - I'm new to UNIX and reg. ex, so this is probably very basic, but I can't figure it out. Given a simple text file called namelist with a list of names such as
John Doe
Bob Cat
Billy Bob
Joe Mama
etc,
the command:
grep '[A-Z][a-z]*' namelist
yields all lines, as it should, an upper case letter followed by 0 or more lower case letters.
yet
grep '[A-Z][a-z]+' namelist
yields nothing. Every line starts with one upper case letter followed by one or more lower case, but this yields nothing.
Also
grep '[A-Z][a-z]\{1,\}' namelist
yields every name on the list. I've found a couple of references that say this is identical to the 2nd grep command above (one ore more lower case letters), yet this lists the names, as I would expect, but the [a-z]+ syntax does not.
Can someone explain this to me?
Thank You,
Doug