Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Regex ERROR!

by nofernandes (Beadle)
on Jul 15, 2003 at 09:58 UTC ( [id://274335]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex ERROR!
in thread Regex ERROR!

Thank you Very much!!!
In did the \Q was the problem!!!

It might be a stupid question but what does the \Q does in this context??

Thank you again for your help!!

Has in my country they said "The one that doesn´t know is like the one that cannot see!!"

Replies are listed 'Best First'.
Re^3:: Regex ERROR!
by flounder99 (Friar) on Jul 15, 2003 at 12:35 UTC
    from the perlre man page
        \Q    quote (disable) pattern metacharacters till \E
    
    look at this code:
    $comm = '(xyz'; $line = '123(xyz)456'; if ($line =~ /$comm/) { #error! same as $line =~ /(xyz/ which ha +s an unmatched '(' # do stuff } if ($line =~ /\Q$comm/) { #no error! same as $line =~ /\(xyz/ -- ' +(' is escaped # do stuff }

    --

    flounder

      Hmm..

      Ok.. i get it!! Thank you very much!

      nofernandes
      And I'd like to add that `perldoc perlop' says:
      \Q          quote non-word characters till \E
      
      Which means
      $a = "\Qhello! there? How> what< now%"; die $a; __END__ hello\!\ there\?\ How\>\ what\<\ now\% at - line 2.

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-24 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found