Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: backslash in regex

by JaWi (Hermit)
on Feb 02, 2003 at 10:49 UTC ( #231982=note: print w/replies, xml ) Need Help??

in reply to backslash in regex

The \Q disables pattern metacharacters until a \E is found, thus, if you wrote your regexp like:
if ( $dir =~ /^\Q$fav\E\\/ ) { # Note the \E after $fav!
It will match the stuff you want...

Update: placed the \E at the wrong place...

-- JaWi

"A chicken is an egg's way of producing more eggs."

Replies are listed 'Best First'.
Re: Re: backslash in regex
by Pardus (Pilgrim) on Feb 02, 2003 at 11:00 UTC
     if ( $dir =~ /^\Q$fav\\\E/ ) { # Note the \E at the end! won't work -- the problem is under \Q modifier the backslash at the end matches wrong  if ( $dir =~ /^\Q$fav\E\\/ ) { works
    Jaap Karssenberg || Pardus (Larus)? <>
    >>>> Zoidberg: So many memories, so many strange fluids gushing out of patients' bodies.... <<<<
Re: Re: backslash in regex
by arc_of_descent (Hermit) on Feb 02, 2003 at 11:01 UTC

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2022-08-13 09:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found