HELP !!! (Capture text between html tags)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zeny
    New Member
    • Jul 2006
    • 44

    HELP !!! (Capture text between html tags)

    Hey ppl,

    How can we capture text between html tags using regular expressions? For example, how to capture the words "hello", "world", "bla", "bla" and "bla" in the following input:

    <br><i>hello world <br><br> bla bla bla <br>

    Best Regards
  • AaronL
    New Member
    • Jan 2007
    • 99

    #2
    Hello,

    I don't know if this is the absolute best way to do this, but this should help you out:

    This strips any html code out of text, in this case txthtm.text you probably should write a function and replace txthtm.text with a string variable.

    Dim TagStart As Long
    Dim TagEnd As Long
    Dim TagStrip As String
    TagStart = 1
    Do
    TagStart = InStr(TagStart, txthtm.Text, "<")
    If TagStart > 0 Then
    TagEnd = InStr(TagStart, txthtm.Text, ">")
    Else
    TagEnd = 0
    End If
    If TagEnd > TagStart Then
    TagStrip = Mid(txthtm.Text , TagStart, TagEnd + 1 - TagStart)
    txthtm.Text = Replace(txthtm. Text, TagStrip, "")
    TagStart = 1
    Else
    TagStart = 0
    End If
    Loop Until TagStart = 0

    Comment

    • liza1
      New Member
      • Aug 2008
      • 4

      #3
      Following is the example of Capture text between html tags:

      <html>
      <body>

      <script type="text/vbscript">
      document.write( "<h1>Hello World!</h1>")
      document.write( "<h2>bla,bla,bl a </h2>")
      </script>

      </body>
      </html>

      There are number of nice videos Tutorial of VB and HTML on http://codervods.com/Default.aspx?mo de=default&cate gory=VBScript&d ays=All&current Index=0
      This will help you in VB

      Thanks

      Comment

      Working...