簡體   English   中英

如何使用批處理文件在字符串中的數字之間留空格

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

所以最近我正在制作一個批處理文件,然后我做了一個字符串。 后來我需要在字符串中的數字之間留空格(很難描述!)。

例如:字符串是2023 ,我想更改字符串,並使其成為2 0 2 3

我嘗試瀏覽網絡,但我發現的唯一發現可能是這樣的: set %string%=%string:"something here"%

但是我不確定那該寫什么...

感謝您的幫助:D

未經測試:

@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