in reply to Can I use Q and E to regex match the dollar sign?

from the docs perldoc perlre:

You cannot include a literal "$" or "@" within a "\Q" sequence. An unescaped "$" or "@" interpolates the corresponding variable, while escaping will cause the literal string "\$" to be matched. You'll need to write something like "m/\Quser\E\@\Qhost/".

Boris
  • Comment on Re: Can I use Q and E to regex match the dollar sign?

Replies are listed 'Best First'.
Re^2: Can I use Q and E to regex match the dollar sign?
by radiantmatrix (Parson) on Aug 30, 2005 at 19:36 UTC

    So, in other words, the OP would have to move the literal $ outside the \Q\E set, like this:

    like('asdf$',qr/\Qasdf\E\$/);

    The other option, of course, would be something like:

    ## matches a literal '[a-z]$[0-9]' using quoting like( '[a-z]$[0-9]', quotemeta('[a-z]$[0-9]') );
    (As ikegami pointed out above)

    <-radiant.matrix->
    Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
    The Code that can be seen is not the true Code
    "In any sufficiently large group of people, most are idiots" - Kaa's Law