fork(1) download
  1. Imports System
  2. Imports System.Text.RegularExpressions
  3.  
  4. Public Class Test
  5. Public Shared Sub Main()
  6. Dim pattern As String = "(\w+)\((?:\((\d+)\))*\)"
  7. Dim text As String = "(abc())(def((123)(456))(klm((123))"
  8. Dim matches As MatchCollection = System.Text.RegularExpressions.Regex.Matches(text, pattern)
  9. For Each m As Match In matches
  10. Console.WriteLine("Match: " & m.Groups(1).Value)
  11. For Each g As Capture in m.Groups(2).Captures
  12. Console.WriteLine("Capture: " & g.Value)
  13. Next
  14. Next
  15.  
  16. End Sub
  17. End Class
Success #stdin #stdout 0.07s 27324KB
stdin
stdout
Match: abc
Match: def
Capture: 123
Capture: 456
Match: klm
Capture: 123