Created
April 20, 2014 10:22
-
-
Save davidwaterston/c61479f318074ec45325 to your computer and use it in GitHub Desktop.
Javascript: increment the number part of a text field e.g. take a text field containing "abc15" and increment it by 1 to return "abc16", "xyz99" will become "xyz100", etc. Really shouldn't be doing this but if you have to then this will do it. See it in action: http://jsfiddle.net/davidwaterston/a8yXH/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myString = "abc99"; | |
newString = myString.replace(/\d+$/, function(n) { return ++n }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment