Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: not able to replace the element in the middle of the string

by Laurent_R (Canon)
on Jul 12, 2016 at 10:43 UTC ( [id://1167602]=note: print w/replies, xml ) Need Help??


in reply to not able to replace the element in the middle of the string

You have to specify how to determine which "aa" sequence to replace. Assuming you want to replace any "aa" sequence that is neither at the beginning, not at the end, of the string, you may want to use a look-behind and a look-ahead assertion. This is an example under the Perl debugger:
DB<1> $aa = "aabbccddaaffddnnaa"; DB<2> $aa =~ s/(?<=.)aa(?=.)/ee/; DB<3> print $aa aabbccddeeffddnnaa
HTH.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-18 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found