Javascript ReplaceAll with regex and return function

Today I had to do some changes to a string that I can not modify on the creation end. To do this I settled on doing a replaceAll with a replace function!

Since I need to make sure that its a complete tag, I had to use namedGroups to be able to put in the new data where I wanted it.

I think this worked fairly well!

(Mainly posting this to have some recording of it, if I ever need it again)