Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: No need to escape right brace in regex

by no_slogan (Deacon)
on Oct 21, 2014 at 06:57 UTC ( [id://1104526]=note: print w/replies, xml ) Need Help??


in reply to Re: No need to escape right brace in regex
in thread No need to escape right brace in regex

{ is only special if it's followed by /\d+,?\d*}/. If they want to add anything else that can go between { }, they have to either add a simple rule to the language (always backslash { unless you want special behavior), or a bunch of weird rules that they might want to change again later.

} is never special unless a preceding { makes it so.

  • Comment on Re^2: No need to escape right brace in regex

Replies are listed 'Best First'.
Re^3: No need to escape right brace in regex
by syphilis (Archbishop) on Oct 21, 2014 at 08:14 UTC
    But you don't *always* get the deprecation warning:
    C:\>perl -le "$_ =~ /{}/;" C:\>perl -le "$_ =~ /.+{}/;" C:\>perl -le "$_ =~ /a+{}/;" C:\>perl -le "$_ =~ /(a+)?{}/;" C:\>perl -le "$_ =~ /a{}/;" Unescaped left brace in regex is deprecated, passed through in regex; +marked by <-- HERE in m/a{ <-- HERE }/ at -e line 1. C:\>perl -le "$_ =~ /\d{}/;" Unescaped left brace in regex is deprecated, passed through in regex; +marked by <-- HERE in m/\d{ <-- HERE }/ at -e line 1. C:\>
    That behaviour fits ok with the (undetailed) documentation that Athanasius found, but does it tie in at all with the cases you're describing ?
    (I don't see the connection, though that doesn't mean there isn't one :-)

    Cheers,
    Rob
      This is really a bit strange.

      Looks like they are only simplifying parsing of quantifiers like in /a{1,2}/ to avoid look ahead analysis.

      All other cases you've shown can not be quantifiers.

      Maybe the warning should be better phrased?

      Cheers Rolf

      (addicted to the Perl Programming Language and ☆☆☆☆ :)

Re^3: No need to escape right brace in regex
by LanX (Saint) on Oct 21, 2014 at 10:18 UTC
    Hmm I think it's even more complicated, there is still (?{code}) and (??{code}) to handle.

    But yes looks like they are cleaning up some messi parsing rules.

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)

      But yes looks like they are cleaning up some messi parsing rules

      It does look that way - I guess all will become clear eventually.
      In the meantime I'll just escape both '{' and '}'.

      The same warning showed up with the advent of 5.18 (or was it 5.20) and I eradicated those warnings (by escaping the braces) accordingly.
      But 5.21.x has uncovered other situations where braces are unacceptably unescaped - situations that 5.20 and earlier didn't care about.

      Cheers,
      Rob
        I wonder why the warning doesn't simply include the suggested escaping.

        Migration would become easier.

        Anyway \Q aka quotemeta rules! :)

        Cheers Rolf

        (addicted to the Perl Programming Language and ☆☆☆☆ :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-16 23:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found