【发布时间】:2013-11-27 16:38:08
【问题描述】:
我正在尝试使用正则表达式获取 css 选择器 + 样式,但总是有问题...
那么你有一个关于正则表达式的想法(例如?)吗:
array(
[0] => "div {
background: red;
color: blue;
}",
[1] => "section {
/* comment with bad idea } <- this break regexp [^}]+ */
background: blue;
color: red;
}"
);
从这个 css:
div {
background: red;
color: blue;
}
section {
/* comment with bad idea } <- this break regexp [^}]+ */
background: blue;
color: red;
}
谢谢
【问题讨论】:
-
我会从谷歌搜索
PHP Parse CSS开始,查看可用的解决方案,看看他们是否足够聪明,能够抓住这个案例 -
xkcd.com/1171 够清楚
标签: php regex preg-match-all