批處理指令碼 - 字串中間



它用於透過字串中的字元位置來提取子字串。

示例

@echo off 
set str = Helloworld 
echo %str%

set str = %str:~5,10% 
echo %str%

上述程式要注意的關鍵事項是,~5,10 用於指定需要顯示的字元。在這種情況下,我們希望顯示字元 5 到 10。

輸出

上述命令生成以下輸出。

Helloworld 
world
batch_script_strings.htm
廣告