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,548 of 68,980   
   Tom Del Rosso to Herbert Kleebauer   
   Re: Remove all but digits   
   24 May 20 18:49:19   
   
   From: fizzbintuesday@that-google-mail-domain.com   
      
   Herbert Kleebauer wrote:   
   > 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%   
      
   Thank you (all 3).  I incorporated this method and it worked, but   
   yesterday realized that I also had to extract some information about the   
   place in the string where the longest number is.  So I had to scrap the   
   whole routine and use brute force scanning and parsing of each   
   character, which is one of the methods in Zaidy's link.  At least   
   special characters aren't a problem any more.   
      
   Thank you again.   
      
   --- 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