0

Hi Im trying to write a simple CSS parsing script in PHP that enables me to put previously declared classes within a css rule, i.e. the Mixins functionality of less and Sassy.

This regex only grabs the last css class name within the curly braces:

{.+(\.\w+).+}

For example, only .foo will be matched in the below css rule:

.login_form_container  { .gradient .rounded_corners width:431px; height:282px; margin:250px auto 0; .foo }

Thanks!

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Globalz
  • 4,474
  • 6
  • 34
  • 43
  • To be consistent, you'll probably want semi-colons after the class names. – Eric Jul 17 '10 at 14:38
  • possible duplicate of [Parsing CSS by regex](http://stackoverflow.com/questions/236979/parsing-css-by-regex) – Gordon Jul 17 '10 at 15:00

2 Answers2

2

Why don't you just use lessphp?

Eric
  • 95,302
  • 53
  • 242
  • 374
0

Ok, try this one:

{(?:[^\.]*(\.\w+))+[^\.]*}

Eric
  • 95,302
  • 53
  • 242
  • 374