'Is there any way to get specific css using swiftsoup?

Try to get CSS used using swiftsoup

let link = "<div style="background-image:URL(https://xxxx); color:blue">"
link.attr("style"); 

I can get all style from the div by using code link.attr But is there any way to get specific style attr? e.g. I want to get background-image value ?

EDIT

Try using regex

let regex = "background-image:(?i)url?[(]"
print(try item.attr("style"))
print("\(try String(item.attr("style").replacingOccurrences(of: regex, with: "", options: .regularExpression)))")

The output shows: https://xxxxxx) -> Hot to add regex to delete ")" base on that regex ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source