简体   繁体   English

如何使用批处理文件在字符串中的数字之间留空格

[英]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 例如:字符串是2023 ,我想更改字符串,并使其成为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"% 我尝试浏览网络,但我发现的唯一发现可能是这样的: set %string%=%string:"something here"%

But im not sure what to write there then... 但是我不确定那该写什么...

Thanks for the help :D 感谢您的帮助: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%

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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