【
![[疑问]](/static/emoticons/u7591u95ee.png)
】找到一个代码,不过只能提取出链接的网址,没有文字,想要的结果是 一行一个链接文字+网址【
![[疑问]](/static/emoticons/u7591u95ee.png)
】
'工程引用microsoft vbscript regular expression 5.5
Function RegExpTest(patrn, strng) 'patrn:需要查找的字符 strng:被查找的字符串
Dim regEx, Match, Matches ' 创建变量。
Set regEx = New RegExp ' 创建正则表达式。
regEx.Pattern = patrn ' 设置模式。'"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"'
regEx.IgnoreCase = True ' 设置是否区分大小写。
regEx.Global = True ' 设置全程匹配。
Set Matches = regEx.Execute(strng) ' 执行搜索。
For Each Match In Matches ' 循环遍历Matches集合。
RetStr = RetStr & Match.Value & vbCrLf
Next
RegExpTest = RetStr
End Function
Private Sub Command1_Click()
Dim URLRegExp As String, MailRegExp As String, ChiniRegExp As String
Dim FileName As String, sFile As String, MuName As String, Chans As String
Dim i As Long, arr() As String, arr1() As String, arr2() As String
URLRegExp = "http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?" 'URL正则表达式
MailRegExp = "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" '电子邮件正则表达式
ChiniRegExp = "[^\x00-\xff]* "
Open "d:\1.html" For Binary As #1
sFile = Space(LOF(1))
Get #1, , sFile
Close #1
Text1.Text = RegExpTest(URLRegExp, sFile)
End Sub
Private Sub Command2_Click()
'如何获得剪切板Clipboard.GetText中的链接?不通过加载1.html的方式
End Sub