本帖最后由 ArdentMan 于 2011-7-10 12:31 编辑
vbs正则提取- Dim FSO, Path, vbStr, File, REGEX, OutStr
- Path = CreateObject("Wscript.Shell").CurrentDirectory
- Set FSO = CreateObject("Scripting.FileSystemObject")
- For Each File In FSO.GetFolder(Path).Files
- If LCase(FSO.GetExtensionName(File)) = "htm" Then
- vbStr = vbStr & FSO.OpenTextFile(File).ReadAll() & vbCrLf
- End If
- Next
- Set REGEX = New RegExp
- REGEX.Global = True
- REGEX.IgnoreCase = True
- REGEX.Pattern = ".*?<a href=\x22([^<>\s\x22]+)?\x22 target=\x22_blank\x22>.*?\r\n"
- OutStr = REGEX.Replace(vbStr, "$1" & vbCrLf)
- FSO.OpenTextFile("1.txt", 2, True).Write OutStr
- Set FSO = Nothing
- Set REGEX = Nothing
- MsgBox "提取完成!", , "ArdentMan友情提醒"
复制代码
|