javascript - About match()
PHP中文网
PHP中文网 2017-05-19 10:18:34
0
2
502

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)"

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
Peter_Zhu

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()

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template