如何使用正则表达式获取字符串中的方法/函数

问题描述 投票:0回答:1

我正在尝试使用正则表达式

(?<=@func_strtotime\().*[^\(](?=\))

匹配

+{{request.expires_in}} - 300

来自字符串

'Y-m-d H:i:s',@func_strtotime(+{{request.expires_in}} - 300),@func_time(1234)

但是正则表达式当前匹配的结果是

+{{request.expires_in}} - 300),@func_test(1234

如果有人可以更正我的正则表达式,我将不胜感激。

regex pcre
1个回答
0
投票

您的正则表达式过于贪婪。在?之后添加.*以使其变得懒惰:

(?<=@func_strtotime\().*?[^\(](?=\))
© www.soinside.com 2019 - 2024. All rights reserved.