In javascript, I have a string which contains numbers, and I want to increment the values by one.
Example:
var string = "This is a string with numbers 1 2 3 4 5 6 7 8 9 10";
var desiredResult = "This is a string with numbers 2 3 4 5 6 7 8 9 10 11";
Using a regex, is it possible to perform operations (addition in this case) on the matched backreference?
A found a similar question using Ruby:
string.gsub(/(\d+)/) { "#{$1.to_i + 1}"}