How to find all double quote substrings in a string with VB.NET

1 Answer

0 votes
Imports System
Imports System.Text.RegularExpressions

Class Program
	Public Shared Sub Main()
        Dim str As String = "This is a string with ""double-quoted substring1"", and ""double-quoted substring2"" inside."
        Dim pattern As String = """(.*?)"""
        Dim matches As MatchCollection = Regex.Matches(str, pattern)

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



' run:
'
' double-quoted substring1
' double-quoted substring2
'

 



answered May 12, 2025 by avibootz
...