Can anybody help with a valid regex ?
I have a files containing functions like this one
$variable1 = tr ('This was written in % s . ', array ( $year ));
or
tr ('This was written in % s % s . ' ,array ( $month , $year ));
or
tr('some string ')
Strings are always in single quotes.
I need from the text of source which i get with fopen fundtion to extract all strings passed to tr() function. I use php to parse php files. Any help?
UPDATE WOrks:
$fileContents=file_get_contents($file);
preg_match_all("/tr\('(.*?)'/", $fileContents, $matches);
//preg_match_all('/(?<=tr\s?\(\s?\')(?:\\\\.|[^\\\\\'])*(?=\')/i', $fileContents, $matches, PREG_PATTERN_ORDER);
exit(json_encode($matches));