|
下面这段脚本可以解决文本中的空行,我现在遇到在行尾多出来一个空行,比如说文本在"3"这个地方就结束了,可是,光标又挪到下一行了,就停在下一行的行首
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 |
|