How do I parse CSS background-image
, which supports multiple values, which may be none
and functions (e.g. url()
and linear-grad
Looking at the current W3C Candidate Recommendation for CSS3 (in particular, see background-image and uri), it is structured as follows:
= [ , ]*
= | none
= | | | |
... (you can find the rest of syntax for images here)
EDIT:
You will need to parse for matching parenthese or none
then, and the former is not possible with regex. This post has a pseudo code for the algorithm: Python parsing bracketed blocks.