The following string has been retrieved from an element's style attribute, the attribute is a variable and can contain different colors in a particular vertical gradient background:
string = "background: linear-gradient(0deg, rgb(100, 106, 237) 0%, rgb(101, 222, 108) 100%) repeat scroll 0% 0% transparent; display: list-item; cursor: pointer;"
Using the following code, the linear-gradient contents is extracted from the string:
string = string.substring(string.indexOf('linear-gradient('), 1+string.lastIndexOf(')')); // string = "linear-gradient(0deg, rgb(100, 106, 237) 0%, rgb(101, 222, 108) 100%)"
Now using a regular expression -or any other method- I need to extract both the first rgb -rgb(100, 106, 237)- value as-well as the second -rgb(101, 222, 108). Can anyone please recommend/suggest a simple method to achieve this. Thanks in advance.