我正在尝试匹配包含在 % 中但preg_match_all
似乎在同一行中同时包含多个子字符串。
代码如下所示:
preg_match_all("/%.*%/", "%hey%_thereyou're_a%rockstar%\nyo%there%", $matches);
print_r($matches);
这会产生以下输出。
Array
(
[0] => Array
(
[0] => %hey%_thereyou're_a%rockstar%
[1] => %there%
)
)
但是我希望它生成以下数组:
[0] => %hey%
[1] => %rockstar%
[2] => %there%
我错过了什么?