develooper Front page | perl.perl5.porters | Postings from June 2016

RFC: deprecate quantifying zero-length constructs in regex patterns

Thread Next
From:
Karl Williamson
Date:
June 2, 2016 04:56
Subject:
RFC: deprecate quantifying zero-length constructs in regex patterns
Message ID:
574FBC8A.4080700@khwilliamson.com
This came up on another thread, but I think it should get its own airing.

qr/ ^ {1,3} /x, warns with "Quantifier unexpected on zero-length expression"

qr/ ^ * /x warns instead with "^ *  matches null string many times", and 
generates code that will run a very long time.

qr/ ^ ? /x doesn't warn.  Nor does qr/ ^ {0,1} /x.  But qr/ ^ {0,2} /x 
does warn.

It is nonsensical to use a quantifier on an assertion, and for Perl to 
try to do so is not likely at all to be DWIM.  So I believe we should 
deprecate these.




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