简体   繁体   中英

how to make spaces between numbers in a string with a batch file

So i was making a batch file recently, and i made a string. Later i needed to make spaces between the numbers in the string (its hard to describe!).

For example: The string is 2023 , i want to change the string, and make into 2 0 2 3

I tried to browse the web but the only thing i found out was that its probably something like this: set %string%=%string:"something here"%

But im not sure what to write there then...

Thanks for the help :D

Not tested:

@echo off

set "some_string_with_digits=abc1234fgh098jkl"
setlocal enableDelayedExpansion
for %%a in (1 2 3 4 5 6 7 8 9 0) do (
  set "some_string_with_digits=!some_string_with_digits:%%a=%%a !"
)
echo %some_string_with_digits%

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM