I don't know much about how perl/grep interact.  I tried inside perl, a 
case-insensitive replace works, by adding "/i" to the end, e.g:

# echo "TesT" | perl -p -e 's/\Qtest\E/testworks/'
TesT
# echo "TesT" | perl -p -e 's/\Qtest\E/testworks/i'
testworks

As can be seen, 'test' matches 'TesT' even inside the \Q \E as long as the /i 
is provided.

Any suggestions?


--- On Thu, 8/26/10, Paolo Bonzini <[email protected]> wrote:

> From: Paolo Bonzini <[email protected]>
> Subject: Re: How to use \Q \E in GREP in a case-insensitive way?
> To: "Stormy" <[email protected]>
> Cc: [email protected]
> Date: Thursday, August 26, 2010, 1:33 AM
> On 08/25/2010 05:02 PM, Stormy
> wrote:
> > however, when I try to make grep match in a
> case-insensitive way,
> > using -i flag there are no matches, here's an
> example:
> >
> > sh-3.2# echo "TeST" | grep -P
> '\QTeST\E'   ==>  Match, expected
> TeST
> > sh-3.2# echo "TeST" | grep -iP '\Qtest\E' 
> ==>  No match, UNEXPECTED
> >
> > I would expect the last example to match, since the -i
> flag was
> > passed.  I rather stay with grep than to switch
> to perl or parsing
> > the large files manually.
> 
> I think this is unexpected behavior of PCRE, not grep.
> 
> Paolo
>

Reply via email to