试试把下列内容保存为test.vbs,同时把你的a.txt与test.vbs放在相同的目录下,直接运行test.vbs即可。- Dim FSO, objFile, FileName, FileContent
-
- FileName = "F:\a.txt"
-
- Set FSO = CreateObject("Scripting.FileSystemObject")
- Set objFile = FSO.OpenTextFile(FileName, 1, False)
- FileContent = objFile.ReadAll
-
- RetStr=MyRegExp("<a(.+?)href=""*([^\s]+)""([^>]+|>)",FileContent)
-
- FSO.CreateTextFile("Res.txt",True).Write RetStr
-
- Set objFile=Nothing
- Set FSO = Nothing
-
- '/*/////////////////////////////////////////////////////////
- '*MadeTime: 2010-5-31
- '*LastModify: 2010-5-31
- '*功能: 正则提取内容
- '*参数: 正则表达式,处理字符串
- '**********************************************************
- Function MyRegExp(Patrn,strng)
- Dim InsertURL
- InsertURL="http://www.wholesale-watches.org/"
- Set RegEx1=New RegExp
-
- RegEx1.Pattern = Patrn
- RegEx1.IgnoreCase=True
- RegEx1.Global=True
-
- Set Matches =RegEx1.Execute(strng)
- For Each Match In Matches
- RetStr=RetStr & InsertURL & Match.submatches(1) & vbcrlf
- Next
- MyRegExp=RetStr
-
- Set RegEx1=Nothing
- End Function
复制代码
|