I'm in need of a regexp that will allow me to retrieve all the following data from a php source file :
MUI('Some text')
MUI("Some text", $lang)
The regexp is used to extract all the terms enclosed in MUI("...") in a php file in order to build a list of items to translate. I already have the regexp for the first case :
MUI("Some text") > $pattern = '/MUI\((["\'].*?)["\']\)/';
But I had to add a parameter which is a variable and since then my regexp wont find the second case
MUI("Some text", $lang).
Please be aware that the text to find may be enclosed by ' or ". Thanks in advance for your ideas.
MUI("Some ) text", $lang). What you actually need as a tool is not regular expressions, but a language parser that is able to understand the actual structure of a valid PHP file.MUI\((?|"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)')demo