【发布时间】:2015-07-24 10:19:29
【问题描述】:
我有这种多行 CSS 样式:
.style-1 {
border-color: #2980B9;
}
.style-2 {
background-color: #2980B9;
#FFF;
}
.style-3 input[type=submit] {
background-color: #2980B9;
color: #FFF;
}
这是我的正则表达式模式:\..*\{\s?\s?+.*\s?\}\s?\s?+
https://regex101.com/r/tP7qE7/1
我想匹配从选择器到右括号的每条规则,这样我就可以在每条规则之前添加新的选择器并分别回显每条规则。现在,使用上面的正则表达式模式,我只能得到第一条规则。我尝试了preg_match() 和preg_match_all(),但没有成功。如何使用正则表达式匹配每个规则?
提前谢谢你!
【问题讨论】: