TKC Blog
03
 ''' <summary>
 ''' Extract HTML list items from a string usin regular expressions
 ''' Could also be used to extract any HTML tag by modifying the regular expression match
 ''' </summary>
 ''' <returns></returns>
 ''' <remarks></remarks>
 Function ExtractHTMLList() As String
 
    Dim strDoc As String = "adsfasdfadsfad adsfasdf<li class=""on"" id=""333"">adfadsf adfsadf tid=""434"" adsfdsf</li><li id=""38734"">adsfasdfsadf</li><li id=""3454"">adsfadsf</li>adsf adfadsfadsf"
    Dim strTemp As String = ""
 
    Dim lis As MatchCollection = Regex.Matches(strDoc, "<li\b[^>]*>(.*?)</li>")
 
    For Each Match In lis
      strTemp &= HttpUtility.HtmlEncode(Match.ToString) & "<br />"
    Next
 
    Return strTemp
 
 End Function
Search Blog