求一个批处理,删除TXT文件内的中文汉字和所有类型的标点符号以及空格,换行要求保留。

是客户的联系方式,想要删除文档中的汉字和标点符号,只保留电话号码,求批处理代码。

只保留电话号码?

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类型文件
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-03-09
@echo off
(for /f "skip=1 tokens=2 delims=:" %%i in (a.txt) do echo %%i)>b.txt
notepad b.txt本回答被提问者采纳
相似回答