alert('rgb(255)'.match(/rgb\((\d )\)/));
Looking for matches. I don’t understand why ["rgb(255)", "255"] is returned?
["rgb(255)", "255"]
Why not just return "rgb(255)"
"rgb(255)"
认证0级讲师
Because you used capture, that is, the brackets.
console.log('rgb(255)'.match(/rgb\((\d+)\)/));
No need to capture it
console.log('rgb(255)'.match(/rgb\(\d+\)/));
For this kind of problem, please refer to the document directly: String.prototype.match()
Because you used capture, that is, the brackets.
No need to capture it
For this kind of problem, please refer to the document directly: String.prototype.match()