develooper Front page | perl.perl5.porters | Postings from April 2017

Re: [perl #128420] Changes in regex recursion in 5.24

Thread Previous | Thread Next
Karl Williamson
April 11, 2017 16:02
Re: [perl #128420] Changes in regex recursion in 5.24
Message ID:
On 04/11/2017 05:02 AM, demerphq wrote:
>> On 11 April 2017 at 12:36, Jan Goyvaerts <> wrote:
>> Another change I've noticed in Perl 5.24.0 and 5.24.1 compared with previous
>> versions is that [[:AlPhA:]] and [[:w:]] (and seemingly every other single
>> letter class) are no longer errors, but also doesn't seem to match anything
>> (or at least nothing obvious that I could figure out).
> If you notice things like that could file a new ticket please? I am
> sure Karl will want to know.

These are now legal.  The first one warns if warnings are enabled, as 
they always should be:

	Assuming NOT a POSIX class since the name must be all lowercase letters 
in regex; marked by <-- HERE in m/[[:AlPhA:] <-- HERE ]/ at -e line 1.

The single letter constructs, which you assume are meant to be Posix 
classes, don't warn, as none of them are close enough to a legal class 
name that they could have been intended to be one.  That could be 
changed if there was evidence that people think [[:w:]] might mean 
something.  Maybe this is legal in other languages?  Perl uses the names 
in the Posix standard, plus a couple of extensions.

If you want to see what a pattern compiles into, and hence what it matches,

use re qw(Debug COMPILE);
no re;

That shows that [[:w:]] matches a string that contains a ']' immediately 
preceded by one of '[', ':', or 'w'.

It's impossible to figure out for sure what was the programmer's intent.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About