Is there a way to create a function that can replace substrings in a large string based on specific rules?
For instance, I need every digit associated with pageX
in the string to increase by 10.
function replace(str, increment){}
Using
replace("pageX : 100, pageY: 200,......pageX : 120...", 10)
would result in "pageX : 110, pageY: 200,......pageX : 130..."
I am aware of methods like
string.replace(/pageX:/g,someStr)
for simple replacements, but how can I apply specific rules to each replacement?