regex to find function arguments inside php files -



regex to find function arguments inside php files -

can help valid regex ?

i have files containing functions 1

$variable1 = tr ('this written in % s . ', array ( $year ));

or

tr ('this written in % s % s . ' ,array ( $month , $year ));

or

tr('some string ')

strings in single quotes.

i need text of source fopen fundtion extract strings passed tr() function. utilize php parse php files. 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));

if understand question correctly, want regex match strings passed function called tr().

the next regex should do:

/tr\('(.*?)'/

so:

<?php preg_match("/tr\('(.*?)'/", $filecontents, $matches); print_r($matches);

php regex

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -