我正在尝试制作一个Skype解析器并且我已经有了一个API,现在我的所有代码都正常工作,但是它不是只显示它们的IP而是在它前面显示一些html代码,例如: <h1><b>0.0.0.0</b></h1>
,如何从文本框中删除随机文本,此解析程序也是在Visual Basic中创建的!以下是我用来解决的代码,如果有帮助的话:
Try
DownloadResponse = GetResponse.DownloadString("http://SKYPEAPIHERE.com/&name=" & TextBox7.Text)
FormatResponse = DownloadResponse.Split(New Char() {ControlChars.Lf}, StringSplitOptions.RemoveEmptyEntries)
TextBox8.Text = FormatResponse(0)
Dim sText() As String
sText = Split(TextBox8.Text, ":")
If sText(0) = "168.63.55.14" Then
TextBox8.Text = "IP Not Found"
ListBox1.Items.Add("SKYPE RESOLVER: IP Not Found")
Else
TextBox8.Text = sText(-2)
ListBox1.Items.Add("SKYPE RESOLVER: Resolved " + TextBox7.Text + " - " + TextBox8.Text)
End If
Catch ex As Exception
End Try
如果有人可以帮助我,我们将不胜感激!
答案 0 :(得分:2)
如何使用正则表达式匹配IPv4格式?
Imports System.Text.RegularExpressions
Dim regex As Regex = New Regex("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$")
Dim match As Match = regex.Match("<h1><b>0.0.0.0</b></h1>")
If match.Success Then
sText=match.Value
End If
以上未经测试,但希望能指出正确的方向。
http://answers.oreilly.com/topic/318-how-to-match-ipv4-addresses-with-regular-expressions/