Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim dian As String '标志符号判断href链接 Dim hdian As Integer '记录是否有空格后面延迟多少位 Dim hyou As String Dim aa As String '判断A链接标识符 Dim aaa As Integer '判断A链接>出现的位置 Dim str As String '字符串 Dim you As String Dim zuo As String Dim zuozuo As Integer '判断左边的最后一个字符 Dim right As Integer RichTextBox2.Text = "" hdian = 0 hyou = "" RichTextBox1.Text = "<li><a href = ' /luyouqsz/' clsas="">路由器怎么设置</a></li>" str = RichTextBox1.Text For i = 1 To (Len(str)) If (InStrRev(str, "href")) > 0 Then zuo = (Mid(str, 1, ((InStrRev(str, "href")) + 3))) + "=" '截取href左边的字符 'MsgBox(zuo) For j = 1 To 10 dian = Mid(str, (Len(zuo) + j), 1) If dian <> Space(1) And dian <> "=" Then dian = dian hdian = j ' MsgBox(hdian) j = 11 End If Next j ' MsgBox(dian) zuo = zuo + dian RichTextBox2.Text = RichTextBox2.Text + zuo + "[field:arcurl/]" + dian ' MsgBox(zuo) hyou = Mid(str, ((Len(zuo)) + hdian), ((Len(str)) - ((Len(zuo)) - 1))) 'MsgBox(hyou) str = hyou ElseIf (InStrRev(str, "</a>")) > 0 Then 'MsgBox(InStrRev(str, "</a>")) '第一个出现href的位置 zuo = Mid(str, 1, (InStrRev(str, "</a>"))) '</a>左边的所有字符 MsgBox(zuo) you = Mid(str, ((InStrRev(str, "</a>")) + 4), ((Len(str)) - ((InStrRev(str, "</a>")) + 3))) 'MsgBox(you) For j = 1 To Len(zuo) '判断>出现的位置 aa = Mid(zuo, j, 1) If aa = ">" Then aaa = j End If Next j zuo = Mid(str, 1, aaa) '截取href左边的字符 RichTextBox2.Text = RichTextBox2.Text + zuo + "[field:title/]" + "</a>" str = you 'MsgBox(str) Else End If Next i End Sub End Class |
标签: