This will match all named functions.
PHP code to print: $js = file_get_contents('http://somedomain.com/javascript.js'); $regex = "/function\s+(?<functionName>\w+)\s*((?<functionArguments>(?:[^()]+))?\s)\s*(?<functionBody>{(?:[^{}]+|(?-1))*+})/"; preg_match_all($regex, $js, $jsFunctions, PREG_PATTERN_ORDER); echo "<pre>"; echo "<BR><BR>Functions<BR><BR>"; print_r($jsFunctions[1]); //name, arguments is $jsFunctions[2], body is $jsFunctions[3] echo "</pre>";