0
如何获得括号中所有单词的数组?preg_match将文字转换为文本圆括号
$text = 'lorem (try) (table) lorem (try1)';
preg_match('/\((.+)\)/', $text, $coincidencias);
echo $coincidencias;
谢谢。
如何获得括号中所有单词的数组?preg_match将文字转换为文本圆括号
$text = 'lorem (try) (table) lorem (try1)';
preg_match('/\((.+)\)/', $text, $coincidencias);
echo $coincidencias;
谢谢。
使用preg_match_all()
代替preg_match()
和使用nongreedy修改?
在你的正则表达式匹配只直到下一个封闭)
$text = 'lorem (try) (table) lorem (try1)';
preg_match_all('/\((.+?)\)/', $text, $coincidencias);
var_dump($coincidencias);