正则表达式查找字符串中的出现次数,并返回从字符开始到字符结尾的匹配块



我想为以下情况编写一个正则表达式。

我有这个css:

$str = "#button_1589817804107 .omw-custombutton button {font-family:Rubik !important; font-weight:normal !important; font-style:normal !important;}
#button_1589817804307 .omw-custombutton button {color:red}
#button_1589817804407 .omw-custombutton button {font-family:Rubik; font-weight:300 !important; font-style:italic !important;}";

我需要preg_match_all(php(这个字符串,这样我才能找到与魔方匹配的每个匹配项,但它从{返回字符串到最后一个},所以基本上返回了以下找到的匹配数组:

[0]="{font-family:Rubik !important; font-weight:normal !important; font-style:normal !important;}"
[1]="{font-family:Rubik; font-weight:300 !important; font-style:italic !important;}"

我试图弄清楚,但找不到方法。正则表达式不适合我,不幸的是。

布鲁诺, 我必须猜测你想要什么,但这能解决问题吗?

preg_match_all (/^.*Rubik.*$/m, $str, $res);

相关内容

最新更新