本帖最后由 batman 于 2011-5-29 11:42 编辑
vbs正则:- Dim path, fso
- path = "这里改为你的总目录绝对路径"
- Set fso = CreateObject("scripting.filesystemobject")
- search path
- Set fso = Nothing
- MsgBox "ok"
-
- Function search(path)
- For Each file In fso.GetFolder(path).Files
- If fso.GetExtensionName(file) = "txt" Then RegExptest fso.OpenTextFile(file, 1).ReadAll(), file
- Next
- For Each folder In fso.GetFolder(path).SubFolders
- search folder
- Next
- End Function
-
- Function RegExptest(rgstr, file)
- Dim regex
- Set RegEx = New RegExp
- regex.Global = True
- regex.Pattern = "(<[^<>]+>)[^<>]+(<[^<>]+>)"
- vbstr = regex.Replace(vbstr, "$1要替换成的字符$2")
- fso.OpenTextFile(file, 2, 1).Write rgstr
- Set regex = Nothing
- End Function
复制代码
|