|
5#
楼主 |
发表于 2008-9-22 17:36:00
|
只看该作者
srcFile = "c:\delLine1.htm" '需要替换的文本文件
desFile = "c:\delLine2.htm" '替换后的文本文件
pattern = "\n[\s| ]*\r" '匹配空行的正则表达式, 包括含有\v\t\f等
s = ReadFile(srcFile)
Set regEx = New RegExp
regEx.Pattern = pattern
regEx.IgnoreCase = True
regEx.Global = True
s1 = regEx.replace(s,"")
wscript.echo s1
call writeToFile(desFile,s1)
Sub WriteToFile(strFile,str)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(strfile, 2, True)
f.Write str
set f= nothing
set fso=nothing
End Sub
Function ReadFile(strFile)
Dim fso, f
Dim readFile1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(strFile,1)
ReadFile1 = f.ReadAll
set f=nothing
Set fso=nothing
ReadFile=ReadFile1
End Function |
|