I have this simple code (it works, but it is slow):
Code: Select all
@echo off
set mystring=x56x723@c8
echo !%mystring%!
call :NUMBERS_ONLY "%mystring%" mystring
echo !%mystring%!
set mystring=x2c3c4c5v6
echo !%mystring%!
call :NUMBERS_ONLY "%mystring%" mystring
echo !%mystring%!
goto :EOF
:NUMBERS_ONLY
set _source=%~1
set _out=%2
set /a _cnt=0
set newstring=&rem
:00
call set tmpstring=%%_source:~%_cnt%,1%%
if "%tmpstring%"=="" set %_out%=%newstring%&&goto :EOF
if "%tmpstring%"=="0" set newstring=%newstring%%tmpstring%
if "%tmpstring%"=="1" set newstring=%newstring%%tmpstring%
if "%tmpstring%"=="2" set newstring=%newstring%%tmpstring%
if "%tmpstring%"=="3" set newstring=%newstring%%tmpstring%
if "%tmpstring%"=="4" set newstring=%newstring%%tmpstring%
if "%tmpstring%"=="5" set newstring=%newstring%%tmpstring%
if "%tmpstring%"=="6" set newstring=%newstring%%tmpstring%
if "%tmpstring%"=="7" set newstring=%newstring%%tmpstring%
if "%tmpstring%"=="8" set newstring=%newstring%%tmpstring%
if "%tmpstring%"=="9" set newstring=%newstring%%tmpstring%
set /a _cnt=_cnt + 1
goto :00
Output:
Code: Select all
!x56x723@c8!
!567238!
!x2c3c4c5v6!
!23456!
Is it possible to optimize it?
Thanks,
Saso