$_ = "I like the number 4 and I left my dog in the garage last night on accident"; # which I did...poor pup :-/ # store "number xx" where xx is a natural number as a # backreference and replace it with itself followed by # s/(?>number \d+)/ as well as the number 7/g; print $_,$/; __DATA__ output: I like the number 4 as well as the number 7 and I left my dog in the garage last night