Community Patterns

Community Library Entry

1

Regular Expression
Created·2024-05-17 09:12
Flavor·PCRE2 (PHP)

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

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