in reply to Supplying the RHS to a regex as a variable
s/<h2>/<h1>/gi; s#</h2>#</h1>#gi; [download]
You could also use a stylesheet to change the properties of H2 tags and not bother replacing any existing markup.