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

Re: Matching brackets in Regular Expression

by RolandGunslinger (Curate)
on Nov 21, 2003 at 15:15 UTC ( #308919=note: print w/ replies, xml ) Need Help??


in reply to Matching brackets in Regular Expression

I don't understand...what makes the $stub scalar volatile?


Comment on Re: Matching brackets in Regular Expression
Re: Re: Matching brackets in Regular Expression
by jweed (Chaplain) on Nov 21, 2003 at 18:28 UTC
    The problem is that this scalar $stub is volatile and it also contains a little bracket...

    I believe that though he listed that bob(scalar), it should be bob[scalar] as the description lists. In this case it would be interpreted as a character class instead of a string. \Q and \E would backslash these brackets.

    In it's current form, there's really no conflict unless the string is something like bob(??{print $hi}).



    Who is Kayser Söze?
    All code is untested unless I say so.

      Except that the parens () will be used for grouping and capturing by the regex, and so won't match the literals in the string;

      perl -e '$s = q|b(s)|; print "without quotemeta" if $s =~ /$s/; print + "with quotemeta" if $s =~ /\Q$s\E/;' with quotemeta

      qq

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-07-10 11:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (207 votes), past polls