Quote Originally Posted by dynamic_sysop View Post
because the pStyle varies, you would need to make a new regex pattern for each line with that code.
you could do this also, which would avoid the pStyle issue...
Code:
        '/// this pattern will search for the { and the stuff between and the }
        Dim strPattern As String = Regex.Escape("{") & "(.*)}"

        Dim strToSearch As String = "#pStyle03X0 {XXX: 0px;YYYY: 144px;xxxxx:XXXXX: 1000;xxxxx: 498.00; xxxxx:714.00; }"

        Dim rgx As New Regex(strPattern, RegexOptions.IgnoreCase)

        Dim strResult As String = String.Empty
        '/// this will trim the {} off each match as it's found...
        Dim charsToTrim As Char() = {"{", "}"}

        Dim rgxMatches As MatchCollection = rgx.Matches(strToSearch)

        For Each m As Match In rgxMatches
            strResult &= m.Value.Trim(charsToTrim) & Environment.NewLine
        Next

        MessageBox.Show(strResult)
He said he wanted the contents of "#pStyle03X1", not the contents of all of them. I answered his specific question. If you wanted to capture them all:

vb Code:
  1. Dim mCollect As MatchCollection = Regex.Matches("inputstr", "(?<=#pStyle\w*\s{).*?(?=})", RegexOptions.IgnoreCase)
  2.  
  3. For each m As Match in mCollect
  4.     MsgBox(m.Value)
  5. Next