I want to search withing PHP-Files for a special function call. The reason is, that I want to generate .MO-Files for the GetText-Extension. So I first need to create a .PO-Files, which contains all the needed text-strings.
I already find a lot of texts, but there are some problems.
Here is my Regex to find the first Argument of an functioncall:
/\_\([\'|\"]{1}(.+?[^\\\])[\'|\"]{1}[,]{0,1}.*?\)+/si
I need to find function-calls with the following patterns:
_("text");
_("text %s", 3);
_('text');
The Text could contain escaped Quotes. My Problem is acuallty, that I need to know, if there was an apostrophe or an normal quote used for the call.
If I have the call
_('"text"');
then i get the Problem, that I get the text
"text
without the ending quote.
Does anybody of you have an Idea, how I can get my Regex to work?
I would use PHP’s tokenizer for this kind of stuff, not regular expressions: