Try this:
$pattern = '#function
(\w+)\(((?:\$\w+(?:,\s*\$\w+)*?)|\s*)\)\s*\{[.\s]*((?:return\s+[^;]*\s*;)|)[
.\s]*#m';

Notice that \w means:
A "word" character is any letter or digit or the underscore character, that
is, any character which can be part of a Perl "word".

Though, any regexp for this task can be easily fooled; i.e: there's no
regexp for all cases; PHP's language cannot be described properly using just
a regular expression.

Manu.


"Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have tried numerous variations, but my regex skills suck!  I would
> appreciate anyone who can give me a pattern to use in preg_match_all() to
> match the following (I have the first part up to ANYTHING working):
>
> '|function ([\w\d\_]+)\((.*)\)ANYTHINGreturn (ANYTHING);|'
>
> So parsing a PHP file I hope to have 3 backreferences that return the
> "function name", "function args" and "return value (if present)" of all
> functions.
>
> Thanks!
> -Shawn
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to