alert('rgb(255)'.match(/rgb\((\d )\)/));
Looking for matches. I don’t understand why ["rgb(255)", "255"]
is returned?
Why not just return "rgb(255)"
天蓬老师2017-05-19 10:20:34
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+\)/));
大家讲道理2017-05-19 10:20:34
For this kind of problem, please refer to the document directly: String.prototype.match()