In this code snippet below I am trying to get every number that is typed and a string input to be subscribed (as for example in the H2O water formula)
const Reagents = (props) => {
return <div>
<h1>Reagentes</h1>
{props.reagent && props.reagent.map((param, i) =>
<p key={i}>
{param.reagent.replace(/(\d+)/g, '$1'.sub())}
</p>)}
</div>
when i have H2O input it returns
H<sub>2</sub>O