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
'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html