Skip to content

Instantly share code, notes, and snippets.

@kidsil
Created March 20, 2015 14:04
Show Gist options
  • Save kidsil/b91ffbf6e7a158020dbc to your computer and use it in GitHub Desktop.
Save kidsil/b91ffbf6e7a158020dbc to your computer and use it in GitHub Desktop.
Regex Increase number by one (Regex + Math Calculation)
'text_2_moretext'.replace( /(text_)(\d+)(_moretext)/, function( $0, $1, $2, $3 ) {
return $1 + String( parseInt( $2 ) + 1 ) + $3;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment