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

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

Replies are listed 'Best First'.
Re: Re^3:: Regex ERROR!
by nofernandes (Beadle) on Jul 15, 2003 at 13:51 UTC
    Hmm..

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

    nofernandes
Re: Re^3:: Regex ERROR!
by PodMaster (Abbot) on Jul 16, 2003 at 09:17 UTC
    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.