Remove and Replace help.

darklight

Member
Joined
May 3, 2007
Messages
18
Programming Experience
1-3
This is really bugging me. I'm trying to replace and strip text at the same time from an HTML Document. But it still returns the <li> and </li> Here is my code:
VB.NET:
    Function stripit()
        Dim strip1
        Dim strip2
        Dim strip3
        strip1 = AnaG.DocumentText.Remove(0, 2121)
        strip2 = AnaG.DocumentText.Replace("<li>", "")
        strip3 = AnaG.DocumentText.Replace("</li>", "")
        Return strip1 & strip2 & strip3
    End Function
 
You are returning 3 copies of AnaG.DocumentText here combined into one string, one with chars 0-2121 removed, one with "<li>"s removed, and one with "</li>"s removed.

Maybe you want to return only one copy with all those operations applied?
VB.NET:
    Function stripit() As String
        Dim strip As String = AnaG.DocumentText
        strip = strip.Remove(0, 2121)
        strip = strip.Replace("<li>", "")
        strip = strip.Replace("</li>", "")
        Return strip
    End Function
 
Back
Top