On 06/03/11 17:42, Vic wrote:
> 
> Hi All.
> 
> I need some help with regexes in grep.
> 
> I'm trying to search for a pattern along the lines of:
> 
>   foo(bar
> 
> Note that there is no closing bracket.
> 
> Like an eejit, I thought a regex of
> 
>   foo\(.*
> 
> would match that - but grep barfs. It tells me
> 
>   grep: Unmatched ( or \(

Escaping the ( turns **on** it's special meaning to grep, which uses
standard, not extended regex. It differs from python/awk/perl in this sense.

grep 'foo\(bar' is expecting to see a closing \) later in the pattern to
signify the end of a capturing group.

grep 'foo(bar' treats the ( as just another character. This is likely
what you want here.


Stuart
-- 
Stuart Sears RHCA etc.
"It's today!" said Piglet.
"My favourite day," said Pooh.

--
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--------------------------------------------------------------

Reply via email to