Reputation: 155
There is a line containing this:
function dekorator($func, $agrs = [])
{
if (dd){
var_dump("dekorators");
$func();
}
}
if (true)
{
@dekorator
function test()
{
if (ss){
var_dump("tests");
while(){
dd
}
}
}
function dgdg()
{
var_dump("ff");
}
test();
}
I need to get the following:
I wrote a regular expression:
/function?\s+(\w+)*\(([^\)]*)\).*?\{([^\}]+[^\{]+)\}/sim
But there is one BUT, the last function it captures is not the quotation mark (which concerns not the function itself)
The function itself:
function dgdg()
{
var_dump("ff");
}
Superfluous:
test();
}
DEMO: https://regex101.com/r/MTS1pr/1/
Upvotes: 0
Views: 86
Reputation: 992
Use this expression:
function\s+(\w*)\s*\((.*?)\)\s*(\{((?>[^{}]+|(?3))*)\})
Demo: https://regex101.com/r/o0t3fY/2
Upvotes: 1