开发者

Grab every css class name declared between curly braces using regex

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!


Why don't you just use lessphp?


Ok, try this one:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜