tags:

views:

53

answers:

2

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!

+2  A: 

Why don't you just use lessphp?

Eric
Hey thanks for bringing this to my attention, I had been searching for something like this...
Globalz
A: 

Ok, try this one:

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

Eric