I need to parse some text file searching for php classes. So, for example, if I have a text file with this source:
... some text ...
... some other text ...
class Foo{
function Bar($param){ ... do stuff ... }
}
... some other text ...
class Bar{
function Foo(){ ... do something .... }
}
... some else ...
In this case, my regular expression must match the two classes and the content of the classes, to get back this results:
first result:
class Foo{
function Bar($param){ ... do stuff ... }
}
second result:
class Bar{
function Foo(){ ... do something .... }
}
I've tried a lot of times but unlucky. My last test was
/^[\n\r\t ](?:abstract|class|interface){1}(.)[^(?:class|interface)]*$/im
but it only matches
class Foo{
and
class Bar{
without the content of the class.
Thanks for your help :)