How to match words in a string that are wrapped in curly brackets using RegEx with VB.NET

1 Answer

0 votes
Imports System
Imports System.Text.RegularExpressions

Public Class Program
	Public Shared Sub Main()
        Dim input As String = "This is a {string} with {multiple} {words} wrapped in curly brackets."
        Dim pattern As String = "\{([^}]*)\}"
		
        Dim matches As MatchCollection = Regex.Matches(input, pattern)

        For Each match As Match In matches
            Console.WriteLine(match.Groups(1).Value)
        Next
    End Sub
End Class



' run:
'
' string
' multiple
' words
'

 



answered Mar 18 by avibootz
...