Javascript RegEx , Find Text in Between Square Brackets
Find:
ellora[sidebar-1]
and replace only the number, specially finding text in between squa开发者_开发问答re brackets (both opening and closing) and replace.
Using replace()
method.result
should be like this
ellora[sidebar-2], ellora[sidebar-3], ...
Something like this:
s = s.replace(/(\w+\[\w+[_-])(\d+)(\])/g, function(str, p1, p2, p3) {
return p1 + (parseInt(p2) + 1) + p3;
});
精彩评论