bug-grep
[Top][All Lists]
Advanced

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

Re: How to use \Q \E in GREP in a case-insensitive way?


From: Stormy
Subject: Re: How to use \Q \E in GREP in a case-insensitive way?
Date: Thu, 26 Aug 2010 10:01:58 -0700 (PDT)

Here is a workaround:


# echo TesT | perl -ne '/\Qtest\E/ and print'
# echo TesT | perl -ne '/\Qtest\E/i and print'
TesT

Looks like perl on it's own does the right thing, so either its a problem in 
grep or the perl RE library grep uses.

Stormy

--- On Thu, 8/26/10, Stormy <address@hidden> wrote:

> From: Stormy <address@hidden>
> Subject: Re: How to use \Q \E in GREP in a case-insensitive way?
> To: "Paolo Bonzini" <address@hidden>
> Cc: address@hidden
> Date: Thursday, August 26, 2010, 7:28 AM
> 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 <address@hidden>
> wrote:
> 
> > From: Paolo Bonzini <address@hidden>
> > Subject: Re: How to use \Q \E in GREP in a
> case-insensitive way?
> > To: "Stormy" <address@hidden>
> > Cc: address@hidden
> > 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

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