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
  • 665,005
  • 155
  • 1,345
  • 1,328
Globalz
  • 4,244
  • 6
  • 33
  • 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
  • 91,378
  • 50
  • 226
  • 356
0

Ok, try this one:

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

Eric
  • 91,378
  • 50
  • 226
  • 356