In the thred you link to, the discussion is over looping over the keys in a hash. Perhaps I didn't make myself clear in the question. I'm wondering if there's a way to extract the non-html out of the string, concatenate it, lookup the substitution in the hash, and then put the html back in. Something along the lines of:
s|(\w)(<.+?>)(\w+)|$dictionary{$1$3}| if exists $dictionary{$1 . $3};
but now I'm at a loss as to how to put the xml tag back in. I agree that if this is not possible, the alternative is to write all the combinations with the tags into the dictionary hash.