开发者

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;
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜