0
$string="Quick {brown fox jump} over the {lazy dog.}Go back to the forest";
我想exatract字符串,通过{}符号覆盖,从上面$string
,使用正则表达式 我试着用substr
,但它只是给我的第一次出现 我完全地beginer到PHP 请帮帮我..如何提取2个字符php之间的短语?
$string="Quick {brown fox jump} over the {lazy dog.}Go back to the forest";
我想exatract字符串,通过{}符号覆盖,从上面$string
,使用正则表达式 我试着用substr
,但它只是给我的第一次出现 我完全地beginer到PHP 请帮帮我..如何提取2个字符php之间的短语?
使用此:
$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.
)
您可以使用preg_match_all来提取序列。 – chris85