/ Published in: Regular Expression
This finds individual CSS attributes, i.e. "foo : bar;" or "bar : 2px solid foo;"
Expand |
Embed | Plain Text
^\s*[a-zA-Z\-]+\s*[:]{1}\s[a-zA-Z0-9\s.#]+[;]{1}
Comments
Subscribe to comments
You need to login to post a comment.

This will only capture the first attribute value pair, but if there are multiple attributes they are not capured.
I created a regex that will capture all of the attributes
\s(?[a-zA-Z-]+)\s[:]{1}\s*(?[a-zA-Z0-9\s.#]+)[;]{1}