Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: Perl Regular Expression inconsistency

by hv (Prior)
on Mar 14, 2006 at 21:00 UTC ( [id://536696]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Perl Regular Expression inconsistency
in thread Perl Regular Expression inconsistency

I think this is a kind of Huffman coding issue - in regular expressions, parens are far more often used for capturing than for literal matching; on balance a lone paren is more likely to be intended to be part of a capturing pair, so it makes sense to assume that and raise an error.

Braces on the other hand are rarely used in their meta sense, so it helps more people to assume that braces are intended for a literal match except when they strictly match the pattern required to express a repetition count.

That I think is the intention, at least. You could argue that it should be inverted - that because the meta braces are used more rarely, the average user needs more help to use them correctly - but for this kind of trade-off perl tends to favour the expert user rather than the learner.

Hugo

  • Comment on Re^4: Perl Regular Expression inconsistency

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://536696]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-23 19:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found