I want to replace 0
in widget-cadr_testimonials[1][slides][0][slide_title]
var patt1=/\d+/g;
// this is returning the two found integers 1,0 and I need only 0 and want to replace it
var str="widget-cadr_testimonials[1][slides][0][slide_title]";
var patt1=/\d+/g;
document.write(str.match(patt1));
str.replace(/\d+([^\d]+)$/,'x$1');//Where 'x' is your replacement
To just get the matched number you can debug:
str.match(/(\d+)[^\d]+$/)[1]
Or if you want to be more specific about the text either side:
str.replace(/\[\d+\](\[slide_title)/,'[x]$1')
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments