$re = '/(\w+)\((?:[^()]+|(?R))*+\)/m';
$str = 'Attribute VB_Name = "mdl_WbkInits"
Option Compare Database
Function InitWbk_004(byRef wbkRef x ())
Dim wbk As wbk_004_InstoreBrief
Set wbk = New wbk_004_InstoreBrief
Call wbk.wbk_Init(wbkRef)
Set InitWbk_004 = wbk
End Function
Public Function InitWbk_003(ByRef wbkRef As Object) As Object
Dim wbk As wbk_003_3DCalculation
Set wbk = New wbk_003_3DCalculation
Call wbk.wbk_Init(wbkRef)
Set InitWbk_003 = wbk
End Function
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php