I am trying to get so it searches for just one row and returns the value. Right now my regex isn't working at all but guessing because it's not looking at first occurance.
How do I write the regex to find the first <tr><td>Description</td><td></td></tr>?
HTML Code:<tr style="background-color:#EFF3FF;"> <td style="background-color:#DEE8F1;font-weight:bold;">Item</td><td>BOX123</td> </tr><tr style="background-color:White;"> <td style="background-color:#DEE8F1;font-weight:bold;">Description</td><td>Box 1 with blah blah</td> </tr><tr style="background-color:#EFF3FF;"> <td style="background-color:#DEE8F1;font-weight:bold;">Color</td><td>White</td> </tr><tr style="background-color:White;"> <td style="background-color:#DEE8F1;font-weight:bold;">Quantity</td><td>4</td> </tr>Code:Function GetItem(ByVal sHTML As String, ByVal sLabel As String) As String Dim options As RegexOptions = RegexOptions.IgnoreCase Or RegexOptions.Multiline Dim re As Regex = New Regex("<tr style="".*""> <td style="".*"">" & sLabel & "<\/td><td>(?<returnval>.*)<\/td> <\/tr>", options) Dim sRetVal As String = "" Dim mc As MatchCollection = re.Matches(sHTML) For Each m As Match In mc sRetVal = m.Groups("returnval").Value Next Return sRetVal End Function




Reply With Quote