求一个批处理,删除TXT文件内的中文汉字和所有类型的标点符号以及空格,换行要求保留。
2个回答
展开全部
只保留电话号码?
file="1.txt" '文件路径
set open=createobject("scripting.filesystemobject")
function replacestr(byval text)
j = Text
For Each i In Split(Text, vbCrLf)
For k = 1 To Len(i)
If IsNumeric(Mid(i, k, 1)) = False Then
If Mid(i, k, 1) <> NL And Mid(i, k, 1) <> Space(1) Then j = Replace(j, Mid(i, k, 1), "")
End If
Next
Next
replacestr=j
end function
read=open.opentextfile(file).readall
str=split(trim(replacestr(read)),vbcrlf)
for each i in str
if i<>"" then newstr=newstr&i&vbcrlf
next
newstr=left(newstr,len(newstr)-2)
open.createtextfile("change_"&file).write newstr
'保存为vbs类型文件
file="1.txt" '文件路径
set open=createobject("scripting.filesystemobject")
function replacestr(byval text)
j = Text
For Each i In Split(Text, vbCrLf)
For k = 1 To Len(i)
If IsNumeric(Mid(i, k, 1)) = False Then
If Mid(i, k, 1) <> NL And Mid(i, k, 1) <> Space(1) Then j = Replace(j, Mid(i, k, 1), "")
End If
Next
Next
replacestr=j
end function
read=open.opentextfile(file).readall
str=split(trim(replacestr(read)),vbcrlf)
for each i in str
if i<>"" then newstr=newstr&i&vbcrlf
next
newstr=left(newstr,len(newstr)-2)
open.createtextfile("change_"&file).write newstr
'保存为vbs类型文件
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询