I have this string:
var s = '<span style="font-size:13px">20<div class="lblTitle"></div><span>';
I’d like to replace the 20 to 40, I tried:
a.replace(/>(\d*)</, 40)
But it will result in:
<span style="font-size:13px"40div class="lblTitle"></div></span>
the > and < are replaced too…
What should I do?
You could match the
>and<and then put them next to the replacement:or simply use:
You are replacing this in string, so you don’t need the replacement to be an integer.