alert('rgb(255)'.match(/rgb((d+))/));
寻找匹配项 搞不懂为何返回["rgb(255)", "255"]?
["rgb(255)", "255"]
为何不是只返回"rgb(255)"
"rgb(255)"
认证0级讲师
因为你用了捕获,就是那个括号。
console.log('rgb(255)'.match(/rgb\((\d+)\)/));
不用捕获就对了
console.log('rgb(255)'.match(/rgb\(\d+\)/));
这种问题请直接翻文档:String.prototype.match()
因为你用了捕获,就是那个括号。
不用捕获就对了
这种问题请直接翻文档:String.prototype.match()