home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch.nt      Fun with Windows NT batch files      68,980 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 67,541 of 68,980   
   Herbert Kleebauer to Tom Del Rosso   
   Re: Remove all but digits   
   22 May 20 20:28:52   
   
   From: klee@unibwm.de   
      
   On 22.05.2020 16:30, Tom Del Rosso wrote:   
   > The objective is to remove everything except digits 0-9 from a string.   
   >   
   > %alpha_substrings% does contain all possible non-numeric substrings   
   > (space separated), so this should remove them and leave only the digits.   
   >   
   > set "only_numbers=string"   
   > for %%t in (%alpha_substrings%) do (   
   >          call set "only_numbers=%%only_numbers:%%t= %%"   
   > )   
   >   
   > But some characters in the non-numeric substrings, like =, don't get   
   > removed because they are never included in %%t.   
      
   If there is only a problem with "=" you can use:   
      
   @echo off   
   set a=3x3=4+5 = 1 + 8   
   echo %a%   
      
   set b=   
   for %%i in (%a%) do call set b=%%b%%%%i   
   echo %b%   
      
   set d=%b%   
      
   set c=   
   :loop   
   for /f "tokens=1* delims=0123456789" %%i in ("%b%") do set c=%c% %%i&set b=%%j   
   if not [%b%]==[] goto :loop   
   echo %c%   
      
   for %%i in (%c%) do call set d=%%d:%%i=%%   
      
   echo %d%   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca