develooper Front page | perl.perl5.porters | Postings from October 2014

Re: Expected behavior of \Q inside a bracketed character class?

Thread Previous | Thread Next
From:
Marco Moreno
Date:
October 15, 2014 05:25
Subject:
Re: Expected behavior of \Q inside a bracketed character class?
Message ID:
DB03FD23-F110-4B19-AF26-6095BDC682DF@pobox.com
Ugh, I meant to say that this returns false instead of true:

	perl -e 'print “foo" =~ /[\Qa-z\E]/ ? "true" : "false”'


> On Oct 15, 2014, at 1:16 AM, Eric Brine <ikegami@adaelis.com> wrote:
> 
> On Wed, Oct 15, 2014 at 12:30 AM, Marco Moreno <mmoreno@pobox.com <mailto:mmoreno@pobox.com>> wrote:
> Using a \Q inside a bracketed character class, should this return true or false?  This returns "false" for my 5.18.2 and 5.20.0 installs.
> 
> 	perl -e 'print "foo"=~ /\Q[a-z]\E/ ? "true" : "false"'
> 
> It's not inside a bracketed class, not that it matters. \Q..\E doesn't know anything about regular expressions. It escapes non-word characters after interpolating, so
> 
> /\Q[a-z]\E/
> 
> is the same thing as
> 
> /\[a\-z\]/
> 


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