in reply to Supplying the RHS to a regex as a variable

How about a simple:

s/<h2>/<h1>/gi; s#</h2>#</h1>#gi;

You could also use a stylesheet to change the properties of H2 tags and not bother replacing any existing markup.