Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Specific substitution in regular expressions

by jonadab (Parson)
on Sep 17, 2008 at 10:20 UTC ( #711951=note: print w/ replies, xml ) Need Help??


in reply to Specific substitution in regular expressions

Lookbehind and lookahead will work in the specific example you give, but the more general solution, which will still work if the surrounding stuff can vary in width, is to capture the surrounding stuff and substitute it back:

$line =~ s/(12345)(99)(1234599)/$1$replace$3/;
-- 
We're working on a six-year set of freely redistributable Vacation Bible School materials.


Comment on Re: Specific substitution in regular expressions
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2014-11-28 19:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (200 votes), past polls