Tom Del Rosso
2020-05-22 14:30:58 UTC
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 FOR/F is used then it includes those characters because they are not
seen as delimiters, but it doesn't spit them out one at a time in
multiple loops.
I'm tempted to use GWBASIC (MS just made it open-source!).
--
%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 FOR/F is used then it includes those characters because they are not
seen as delimiters, but it doesn't spit them out one at a time in
multiple loops.
I'm tempted to use GWBASIC (MS just made it open-source!).
--