Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2015-12-01 08:20 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (796 votes), past polls