I want a function which can replace substring in a big string with specific rule.
for example, I want every digit for pageX in the string increase by 10.
function replace(str, increment){}
doreplace("pageX : 100, pageY: 200,......pageX : 120...", 10)
will get "pageX : 110, pageY: 200,......pageX : 130..."
I know that like string.replace(/pageX :/g,someStr) can do replaceAll, but no rule can be applied.
How can I get that?
How about using
replacefunction callback:DEMO: http://jsfiddle.net/ytptN/