Плохо
прочитали:
<div>2H2 + UO2(NO3)2 != (2H)2O</div>
<script>
var div = document.getElementsByTagName('div')[0],
formula = div.innerHTML,
newFormula = formula.replace(/([\w)])(\d)/g, function(){
return arguments[1] + '<sub>' + arguments[2] + '</sub>';
});
div.innerHTML = newFormula;
</script>