in reply to Replacing exactly the found instance in REGEX

Then use s///:
$string =~ s/(traderid)(.*?)(traderid)/${1}myword${3}/s;

Replies are listed 'Best First'.
Re^2: Replacing exactly the found instance in REGEX
by gwadej (Chaplain) on Dec 09, 2008 at 14:46 UTC

    To extend what JavaFan is saying, you can use the s/// operator in place of the test and substitute. In your example there doesn't seem to be any reason to test the string first.

    G. Wade