uh i found out u dn't really need to make preg replace for the _ as when i done it in my script i dn't need to add no _ i just did without pregreplace and my script is a bit safer. try using a if function if the lvl higher than 30 just display the lvl but if its lower make it display a field to add the number for lower lvls.
here is the link if you want to see my one
http://icefuzion.com
but i haven't made the if function yet for lower lvl im just using a normal one and also i am not saving no image file so its all done through server memory
and also i didn't add the combat calculator because im trying to make my own if only someone tried calculus (teacher told me it solve pratically anything) or we could use mathematica(software) to solve the problem.