Javascript Regular Expression for rgb values

后端 未结 9 1306
名媛妹妹
名媛妹妹 2020-12-18 21:15

I\'m trying to get the individual values of a rgb string. I\'ve been getting close, but I\'m just hitting a wall. I\'m looking to do something like this:

v         


        
9条回答
  •  没有蜡笔的小新
    2020-12-18 21:31

    Try this regex:

    /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/
    

    It will capture the r value into $1, the g value into $2, and the b value into $3

提交回复
热议问题