【发布时间】:2009-02-02 18:14:33
【问题描述】:
我有一个看起来像“(3) New stuff”的字符串,其中 3 可以是任意数字。
我想增加或减少这个数字。
我想出了以下方法:
var thenumber = string.match((/\d+/));
thenumber++;
string = string.replace(/\(\d+\)/ ,'('+ thenumber +')');
有更优雅的方法吗?
【问题讨论】:
标签: javascript regex