Skip to content
Advertisement

Match a PHP class with a Regular Expression

I wanna catch Php classes from a file:

JavaScript

and the result matches must be

JavaScript

and

JavaScript

Advertisement

Answer

regexps are poor at parsing programming languages’ grammars. Consider tokenizer functions instead. e.g. http://php.net/manual/en/function.token-get-all.php see also this http://framework.zend.com/apidoc/core/Zend_Reflection/Zend_Reflection_File.html

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement