Public Class frmRegexParagraph
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String() = GetParagraphs(System.IO.File.ReadAllText("C:\testdata.txt"))
Private Shared Function GetParagraphs(ByVal data As String) As String()
Dim result As New List(Of String)
Dim m As Match = Regex.Match(data, "<p>\s*(.+?)\s*</p>")
m = m.NextMatch()
You can't really parse HTML with regular expressions. It's too complex. Regular expression won't handle <![CDATA[ sections and reference enities correctly at all.
I recommend Html Agility Pack
This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).
How can I extract repeated paragraphs of data from an html document. Every paragrahp is preceded by the line:
<p><i>Summary as passed House:</i> <br>
You can obtain all Paragraph tags using the WebBrowser control using the following technique:
Dim oElements as HtmlElementCollection
oElements = WebBrowser1.Document.GetElementsByTagName("p")
For each oElement as HtmlElement in oElements
if oElement.InnerHtml.Contains("<i>Summary as passed House:</i>") then
You can parse the rest to get the specific data within the <P> tags
Hope this helps.