我想知道如何在匹配模式后从结果中排除子字符串.例:
<a href="?page1"><?php __('string1');?></a>
<a href="?page2"><?php __("string2");?></a>
Run Code Online (Sandbox Code Playgroud)
我想只获得作为参数传递给__()函数的字符串.我试过这个正则表达式:
'/__\(((\'([^\']+)\')|(\"([^\"]+)\"))/'
Run Code Online (Sandbox Code Playgroud)
但是返回'string1'和"string2"包装在单引号和双引号中.
如何排除单引号和双引号?
我想知道这里的反向引用有什么问题:
preg_match_all('/__\((\'|")([^\1]+)\1/', "__('match this') . 'not this'", $matches);
Run Code Online (Sandbox Code Playgroud)
它应该匹配__('')之间的字符串,但实际上它返回:
match this') . 'not this
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?