It seems you want to match a "word" followed with parenthesized numbers inside parentheses. A generic approach here would cater for scenarios with unknown amount of (num)s inside the parentheses after the word.
You can use
(\w+)\((?:\((\d+)\))*\)
and rely on the Match.Captures property that is accessible in the .NET regex API. Here is a way to access all the group and capture values:
Imports System
Imports System.Text.RegularExpressions
Public Class Test
Public Shared Sub Main()
Dim pattern As String = "(\w+)\((?:\((\d+)\))*\)"
Dim text As String = "(abc())(def((123)(456))(klm((123))"
Dim matches As MatchCollection = System.Text.RegularExpressions.Regex.Matches(text, pattern)
For Each m As Match In matches
Console.WriteLine("Match: " & m.Groups(1).Value)
For Each g As Capture in m.Groups(2).Captures
Console.WriteLine("Capture: " & g.Value)
Next
Next
End Sub
End Class
See this VB.NET demo and the regex demo. Output:
Match: abc
Match: def
Capture: 123
Capture: 456
Match: klm
Capture: 123
The (\w+)\((?:\((\d+)\))*\) regex matches
(\w+) - Group 1: one or more word chars
\( - a ( char
(?:\((\d+)\))* - zero or more repetitions of
\( - a ( char
(\d+) - Group 2: one or more digits
\) - a ) char
\) - a ) char