Posted By

mocha0range on 08/04/09


Tagged

regex css regular expressions styles


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

mocha0range
vali29
chrisjlee
benrudolph


Find CSS Attributes


 / Published in: Regular Expression
 

This finds individual CSS attributes, i.e. "foo : bar;" or "bar : 2px solid foo;"

  1. ^\s*[a-zA-Z\-]+\s*[:]{1}\s[a-zA-Z0-9\s.#]+[;]{1}

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: shekky on November 12, 2009

This will only capture the first attribute value pair, but if there are multiple attributes they are not capured.

Posted By: shekky on November 12, 2009

I created a regex that will capture all of the attributes

\s(?[a-zA-Z-]+)\s[:]{1}\s*(?[a-zA-Z0-9\s.#]+)[;]{1}

You need to login to post a comment.