简体   繁体   中英

How to read regular expression?

I have this code, I know what it does, but I want to understand how.

var color = "rgb(0, 1, 2)";
var digits = /rgb\((\d+), (\d+), (\d+)\)/.exec(color);

can anyone please explain?

/rgb\\((\\d+), (\\d+), (\\d+)\\)/ :

rgb - string
\\( - symbol (
() - group
\\d - digit
\\d+ - at least one digit symbol
, - string
\\) - symbol )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM