Find data in HTML file and display it in a textbox?

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
2 posts Page 1 of 1
Contributors
User avatar
dj1437
VIP - Donator
VIP - Donator
Posts: 504
Joined: Tue Dec 21, 2010 2:02 am

Hi

I have started working on a program which is kind of a bot thing. First it gets the source code from a HTML page and puts it all into a single string. This part is working.

Now in the source code there might contain a line which looks like this:

if('1' == '0' || 'abc' == '123')

123 is always the same and its not important but instead of 'abc' each page has a different string and this is the thing I want to be displayed in my textbox.

So basically I want the program to find a line starting with if('1' == '0' || and then read out the 'abc' value.

Hope you understand what I mean. Thanks cooll;
This is a signature.
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

You could use a regular expression, I'm not good with those but here's one generated from txt2re.com
Code: Select all
        Dim txt As String = "if('1' == '0' || 'GET THIS' == '123')"

        Dim re1 As String = ".*?" 'Non-greedy match on filler
        Dim re2 As String = "\'.*?\'"    'Uninteresting: strng
        Dim re3 As String = ".*?" 'Non-greedy match on filler
        Dim re4 As String = "\'.*?\'"    'Uninteresting: strng
        Dim re5 As String = ".*?" 'Non-greedy match on filler
        Dim re6 As String = "(\'.*?\')"   'Single Quote String 1

        Dim r As Regex = New Regex(re1 + re2 + re3 + re4 + re5 + re6, RegexOptions.IgnoreCase Or RegexOptions.Singleline)
        Dim m As Match = r.Match(txt)
        If (m.Success) Then
            Dim strng1 = m.Groups(1)
            MsgBox(strng1.ToString().Replace("'", ""))
        End If
Works fine cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
2 posts Page 1 of 1
Return to “Coding Help & Support”