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

Re: Re: Matching brackets in Regular Expression

by jweed (Chaplain)
on Nov 21, 2003 at 18:28 UTC ( [id://308996]=note: print w/replies, xml ) Need Help??


in reply to Re: Matching brackets in Regular Expression
in thread Matching brackets in Regular Expression

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.

Replies are listed 'Best First'.
Re: Re: Re: Matching brackets in Regular Expression
by qq (Hermit) on Nov 21, 2003 at 22:54 UTC

    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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://308996]
help
Chatterbox?
and the web crawler heard nothing...

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

      No recent polls found