我在获取文本中的关键字时遇到问题。我有类似的短信
$str = '<?php {{namespace}} {{use}} {{abstract}} class {{pattern}} {{parent}} {{interface}} { {{trait}} {{property}} {{method}} }';
我不会把所有的话都写进去的 {{..}} . 我该怎么做? 谢谢/
{{..}}
您可以像这样使用regex: preg_match_all("/\{\{(.+?)\}\}/", $str, $matches);
preg_match_all("/\{\{(.+?)\}\}/", $str, $matches);
示例如下: https://regex101.com/r/XyG224/1