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..
谁知道为什么(.*?)不起作用?
尝试转义{char并//在preg_match_all中使用RegEx模式:
preg_match_all("/\{lang:(.*?)\}/i", $template, $found_langs);
Run Code Online (Sandbox Code Playgroud)
并且//i在模式结束时是不区分大小写.
| 归档时间: |
|
| 查看次数: |
92 次 |
| 最近记录: |