[SOLVED] Parsing PHP Source Code
Posted: Tue Mar 30, 2004 12:26 pm
OK, got halfway through my reloading modules problem... now, i need a regex that can parse a module file for functions...
The module file is just a file, with PHP functions in it... what i need to do is, grabs the contents of that file, parse for all instances of a a function definition, and parse out each of the function's important parts... function name, arguments, and main function code.
If anyone has a useful regex anywhere,or can make one, i'd sure appreciate it... i had one whipped up myself, but it doesn;t want to work....
Also, here's the code that needs to be parsed:
The regex needs to literally parse out the function's name, arguments, and internal code... for each function in the file. Thanks in advance.
The module file is just a file, with PHP functions in it... what i need to do is, grabs the contents of that file, parse for all instances of a a function definition, and parse out each of the function's important parts... function name, arguments, and main function code.
If anyone has a useful regex anywhere,or can make one, i'd sure appreciate it... i had one whipped up myself, but it doesn;t want to work....
Code: Select all
/function\s?(їa-zA-Z0-9-_]*)\s?\((ї^{]*?)\)\s?\{(.*)\s?(ї^}]*?)/mixseCode: Select all
<?php
function foo($obj, $arg)
{
$data = $arg
return $data;
}
function bar($obj, $arg2)
{
$data = $arg2
return $data;
}
?>