develooper Front page | perl.perl5.porters | Postings from December 2011

Re: [perl #107262] Unmatched \Q \E in regexp should warn

Thread Previous | Thread Next
From:
Abigail
Date:
December 29, 2011 19:12
Subject:
Re: [perl #107262] Unmatched \Q \E in regexp should warn
Message ID:
20111230031153.GA6295@almanda
On Thu, Dec 29, 2011 at 03:54:10PM -0500, Ricardo Signes wrote:
> * Abigail <abigail@abigail.be> [2011-12-29T12:33:05]
> > > Warning on an unmatched \E might make sense.  I'm not sure.  \Q should be
> > > allowed to end peacefully when the string terminates.
> > 
> > \Q is documented to escape all non letter/digit/underscores to the next
> > \E or the end of the pattern, whichever comes first.
> 
> I was pretty sure it was, but didn't find the documentation in the brief look I
> had before posting.  All I found was talk about \Q..\E pairs, with a few
> examples that omitted \E.
> 
> I am definitely opposed to clucking about a missing \E -- but where is it
> documented, so I can find it next time? :)


man perlrebackslash:
       To uppercase or lowercase several characters, one might want to use
       "\L" or "\U", which will lowercase/uppercase all characters following
       them, until either the end of the pattern or the next occurrence of
       "\E", whichever comes first. They provide functionality similar to what
       the functions "lc" and "uc" provide.

       "\Q" is used to escape all characters following, up to the next "\E" or
       the end of the pattern. "\Q" adds a backslash to any character that
       isn’t a letter, digit, or underscore. This ensures that any character
       between "\Q" and "\E" shall be matched literally, not interpreted as a
       metacharacter by the regex engine.



Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About