$string="Quick {brown fox jump} over the {lazy dog.}Go back to the forest";
我希望使用正则表达式从$string
上方用{}符号覆盖字符串
我尝试使用substr
,但它只给我第一次出现
我完全熟悉PHP
请帮帮我..
答案 0 :(得分:0)
使用此:
$string="Quick {brown fox jump} over the {lazy dog.}Go back to the forest";
preg_match_all('/{([^}]+)}/',$string, $matches);
print_r($matches[1]);//$matches[1] contains array of all the matches in parenthesis
输出:
Array
(
[0] => brown fox jump
[1] => lazy dog.
)