Please tell me how to filter out all unknown numbers and letters in a text file and save them to a new text. These numbers and letters are interspersed in the document. For example: Xi Xi Ha Ha 12 Dong Dong ajs, Thinking, Today 0D12
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%i in (test.txt) do (
call :Check "%%i" OK
echo !OK!
)
pause>nul
:Check Process object Return result
set "str=%~1"
set str_=
for /l %%i in (0 1 1000) do (
set tm_str=!str:~%%i,1!
if "!tm_str!"=="" set %2=!str_! & goto :eof
if "!tm_str!"==" " set str_=!str_!!tm_str!
if !tm_str! GTR Z set str_=!str_!!tm_str!
)
| Rater | Score | Time |
|---|---|---|
| mqw624 | +1 | 2010-12-06 19:37 |
set fso = CreateObject("Scripting.FileSystemObject")
set rfile = fso.OpenTextFile("test.txt",1)
set wfile = fso.CreateTextFile("Wfile.txt")
str = rfile.readall
for k = 0 to 9
str = replace(str,k," ") ' Replace numbers 0 - 9 with empty
next
for i = 65 to 90
str = replace(str,chr(i)," ") ' Replace lowercase letters a-z with empty
next
FOR J = 97 TO 122
STR = REPLACE(STR,CHR(J)," ") ' Replace uppercase letters A-Z with empty
NEXT
wfile.write str
wfile.close