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:
Eric Brine
Date:
October 15, 2014 05:16
Subject:
Re: Expected behavior of \Q inside a bracketed character class?
Message ID:
CALJW-qFGbm0UpQrBCYgG9joWJqia+-QDCj6ocQ7nWx-p1+zBNQ@mail.gmail.com
On Wed, Oct 15, 2014 at 12:30 AM, Marco Moreno <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