Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Regex is not working

by kcott (Abbot)
on Oct 03, 2013 at 06:18 UTC ( #1056723=note: print w/ replies, xml ) Need Help??


in reply to Regex is not working

G'day Rahul Gupta,

Your underlying problem is that the value of $value in $query =~ s/$value/$replace/i is being interpolated: $Id and $name evaluate to zero-length strings so $query =~ s/$value/$replace/i is equivalent to $query =~ s//$replace/i (i.e. no substitutions occur). That was a poor guess on my part; see moritz' explanation instead; the fixes, however, are identical. To fix, use

$query =~ s/\Q$value\E/$replace/i;

-- Ken


Comment on Re: Regex is not working
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2015-07-28 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls