Getting first text between " " on line

Posts 1–6 of 6 · Page 1 of 1
Getting first text between " " on line
I'm getting text from a website, as result the websites source is

swfobject.embedSWF(
"Flashgame.swf", "flashcontent"

I want to get the Flashgame.swf. I'm having tons of trouble trying to do this :\
Try something like this. The "" in a string is a little Problem, but can be handle if you use Chr(34) instead.

Code:
Dim text As String = "swfobject.embedSWF(" & Chr(34) & "Flashgame.swf" & Chr(34) & "," & Chr(34) & "flashcontent" & Chr(34)
Dim i As Integer = text.IndexOf(Chr(34))
Dim a As String = text.Substring(i + 1, text.IndexOf(Chr(34), i + 1) - i - 1)

Console.WriteLine(a)

' Output will be: Flashgame.swf
Quote Originally Posted by RoPMadM View Post
Try something like this. The "" in a string is a little Problem, but can be handle if you use Chr(34) instead.

Code:
Dim text As String = "swfobject.embedSWF(" & Chr(34) & "Flashgame.swf" & Chr(34) & "," & Chr(34) & "flashcontent" & Chr(34)
Dim i As Integer = text.IndexOf(Chr(34))
Dim a As String = text.Substring(i + 1, text.IndexOf(Chr(34), i + 1) - i - 1)

Console.WriteLine(a)

' Output will be: Flashgame.swf
I solved this within a few mins of making the thread.


Btw you're code isn't what I'm looking for anyways. I wanted to beable to find the flash.swf without knowing the name of it.

Like here is the one i did for dragonfable, I've done this for three different
Code:
    Sub getswf()
        Dim sourcecode As String = String.Empty
        Try
            Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://dragonfable.battleon.com/game/")
            Dim response As System.Net.HttpWebResponse = request.GetResponse()
            Dim sr As System****.StreamReader = New System****.StreamReader(response.GetResponseStream())
            sourcecode = sr.ReadToEnd
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Dim Fst As Integer = sourcecode.IndexOf("strFileName=")
        Dim Snd As String = sourcecode.Substring(Fst, sourcecode.Length - Fst) : sourcecode = Snd
        Dim Thrd As Integer = sourcecode.IndexOf("','width','750','height','550','bgcolor','#530000','src','gamefiles/core','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','gamefiles/core' ); //end AC code</script>")
        Dim Frth As String = sourcecode.Substring(0, Thrd)
        Dim Final As String = Frth.Replace("strFileName=", "")
        TextBox1.Text = "http://dragonfable.battleon.com/game/gamefiles/core.swf?strFileName=" & Final

    End Sub
Well it is not even more you did there, just more complicated.
Just improve your code a little, to save lines.
how about this for AQ

Code:
  Sub getswf()
        Dim sourcecode As String = String.Empty
        Try
            Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://aq.battleon.com/Build30/game.asp?launchtype=medium")
            Dim response As System.Net.HttpWebResponse = request.GetResponse()
            Dim sr As System****.StreamReader = New System****.StreamReader(response.GetResponseStream())
            sourcecode = sr.ReadToEnd
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 Dim Fst As Integer = sourcecode.IndexOf("engine/") : Dim Snd As String = sourcecode.Substring(Fst, sourcecode.Length - Fst) : sourcecode = Snd : Dim Thrd As Integer = sourcecode.IndexOf("/>") : Dim Frth As String = sourcecode.Substring(0, Thrd) : Dim Fith As String = Frth.Replace("engine/", "") : Dim Final As String = Fith.Replace("""", "")
        TextBox1.Text = Final
    End Sub
RegEx might work better.
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us