$dummy=$string; while($dummy=~ m/(reg)(ex)/g) { $string=~ s/$1$2/$1ister/; }