Preg匹配都不会找到字符串

Jor*_*ing 1 php regex preg-match-all

我的preg_match_all功能:

preg_match_all("{lang:(.*?)}", $template, $found_langs);
Run Code Online (Sandbox Code Playgroud)

模板如下:

<h1>{lang:Choose sport}</h1>
Run Code Online (Sandbox Code Playgroud)

但它不会找到它...但是如果我使用它:

preg_match_all("{lang:(\w*)}", $template, $found_langs);
Run Code Online (Sandbox Code Playgroud)

它会找到Choose.我需要找到Choose sport..

谁知道为什么(.*?)不起作用?

Vic*_*sky 7

尝试转义{char并//preg_match_all中使用RegEx模式:

preg_match_all("/\{lang:(.*?)\}/i", $template, $found_langs);
Run Code Online (Sandbox Code Playgroud)

并且//i在模式结束时是不区分大小写.