in reply to Specific substitution in regular expressions

What I do in cases like this is to use look-around assertions:
s/(?<=12345)99(?=1234)/$variable/g;

Of course no /g is needed when only one instance should be replaced.

Replies are listed 'Best First'.
Re^2: Specific substitution in regular expressions
by cstrong (Beadle) on Sep 17, 2008 at 10:20 UTC
    Thanks guys. The look ahead / behined assertion method and breaking down the regex in to more matches look like what I need.