Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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
Replies are listed 'Best First'.
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 lurking in the Monastery: (14)
As of 2015-07-31 10:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls