How would I extract the RBG value from the following string?:
let string = "<span style=\"background-color: rgb(230, 0, 0);\">
I would like to get extract "rgb(230, 0, 0)"
from the background-color
value, so I can convert it to a hex string and update some UI.
let range = string.range(of: "\"background-color: ")
let startPoint = range.location + range.length
let subString = string.substring(from: startPoint)
//generating error claiming 'cannot convert value of type 'int' to expected argument type 'string.index'.
//paused here to ask S.O b/c I do not think substrings is the best way to do this, maybe there is a library that extracts values from html elements, or regex?