Regular Expressions 101

Community Patterns

123...6

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
(\s+)(?:abstract\s+|final\s+|private\s+|protected\s+|public\s+)?(?:static\s+)?(function)\s+(\w+)\s*(\((?>[^()]+|(?R))*\))|({(?>[^{}]+|(?R))*})
/
ixgms

Description

Capture PHP Function/Class Methods

Use regular expression to capture the whole method/function. Parse static PHP code for functions and class methods. Useful for getting tokens and possibly use to generate a Call-Graph for debugging.

Submitted by chipgraphics#gmail.com - 6 months ago