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

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

Thread Previous | Thread Next
From:
Jan Goyvaerts
Date:
April 12, 2017 06:03
Subject:
Re: [perl #128420] Changes in regex recursion in 5.24
Message ID:
58EDC30A.6090702@jgsoft.com
Karl Williamson wrote:

 > 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.

Dinkumware's implementation of std::regex (and possibly other 
implementations) support [:w:], [:s], and [:d:] as shorthands for 
[:word:], [:space:], and [:digit:].

Boost::regex additionally supports [:v:] and [:h:] to match vertical and 
horizontal whitespace.

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

Thanks for the tip.

 > 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.

If the programmer intended to add a literal : to the character class 
then a single : would suffice.

Anyway, Perl 5.24's behavior is fine.  It's just that the change took me 
by surprise.  It certainly doesn't break any existing regexes when 
porting code from 5.22 to 5.24.

Kind regards,
Jan Goyvaerts

--
http://www.just-great-software.com

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