The below code is a sample of how to do it. Notice the regex pattern, it is modified to allow each part of the pattern to be put in a named group, which you can access from the match result to get that part of the info. Each match now has a group for the section name, and a group for the section body, and each group of each section is displayed in a messagebox...
VB Code:
Dim MyText As String = IO.File.ReadAllText("c:\test.txt") 'file with pasted text Dim RegexPattern As String = """(?<SectionName>\w*?)""(?<SectionBody>.*?\{.*?\})" Dim MyMatches As System.Text.RegularExpressions.MatchCollection = _ System.Text.RegularExpressions.Regex.Matches( _ MyText, RegexPattern, System.Text.RegularExpressions.RegexOptions.Singleline) For Each Match As System.Text.RegularExpressions.Match In MyMatches MessageBox.Show(Match.Groups("SectionName").Value) MessageBox.Show(Match.Groups("SectionBody").Value) Next




Reply With Quote