开发者

use regexp to search function calls in code

开发者 https://www.devze.com 2023-03-06 12:49 出处:网络
i try to make .mo files from my sources in php by finding \"t()\" function calls, i know that one better way is using regex functions like preg_match or something, but i\'m not the better creating reg

i try to make .mo files from my sources in php by finding "t()" function calls, i know that one better way is using regex functions like preg_match or something, but i'm not the better creating regular expresions,开发者_开发知识库 any help?

(and sorry for my english...)


No, preg_match is not better. When you want to parse PHP code, use the tokenizer. It is far more reliable.


Assuming that you have no function calls within the t() call, the simplest way to match them is

t\([^)]*?\)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号