fork download
  1. Imports System
  2. Imports System.Text.RegularExpressions
  3.  
  4. Public Class Test
  5. Public Shared Sub Main()
  6. Dim s As String = "( )yourstring()somevalue( )getit()"
  7. 'A sample string.
  8. Dim rgx As New Regex("(?<BraceGroup>\([ ]*\))", RegexOptions.Singleline)
  9. 'Regex pattern to match '( )' or '()'.
  10. Dim matches As MatchCollection = rgx.Matches(s)
  11. 'Get all matches.
  12. Dim count As Integer = matches.Count
  13. 'Number of matches.
  14. Console.WriteLine(String.Format("Total groups found : {0}", count))
  15. End Sub
  16. End Class
Success #stdin #stdout 0.09s 18896KB
stdin
Standard input is empty
stdout
Total groups found : 4