I have a long string where I need to increment every number within it, leaving the rest of the text as it is.
I'm using this function
newHtml = newHtml.replace(/\d+/, function (val) { return parseInt(val) + 1; });
Which works great on numbers that are in free text but fails when the numbers are surrounded by square brackets. Example:
<input id="Form[0]_Phone" name="Form[0].Phone" type="text" value="">
Needs to become
<input id="Form[1]_Phone" name="Form[1].Phone" type="text" value="">
I've used this example to try and help, and I've tried a few variations but my regex skills have failed me.
Any assistance much appreciated.