in reply to multiple matches in a string

... which works on the first instance, but leaves the rest untouched.

Consult whatever documentation you have on hand (perlre, if you have the on-line docs), and meditate on the meaning of /g