Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: "exact" pattern matching

by spacebat (Beadle)
on Jun 10, 2008 at 02:13 UTC ( #691138=note: print w/ replies, xml ) Need Help??


in reply to "exact" pattern matching

I agree with CountZero, it sounds like you want index() to get the starting position of the substring, then you can use substr() as an lvalue to assign your replacement string.

However this sounds like what regular expressions were designed for, so either quotemeta() or the following may be a better fit:

s/\Q$pattern\E/$replacement/g


Comment on Re: "exact" pattern matching
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2014-11-24 00:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (134 votes), past polls