Javascript examples for RegExp:Match Number
Increase each number in a string with regex
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//w w w . ja va2 s. c o m console.log("test[test][1][name][2]".replace(/\[(\d+)\]$/g, function(match, number) { return "[" + (Number(number) + 1) + "]"; })); }); </script> </head> <body> </body> </html>