批處理指令碼 - 字串右



這用於從字串末尾中提取字元。

示例

@echo off 
set str = This message needs changed. 
echo %str% 

set str = %str:~-8% 
echo %str%

關於上個程式需要注意的關鍵是,使用~-'提取的字元數量'運算子可提取字串右側內容。

輸出

上述命令輸出如下。

This message needs changed. 
changed.
batch_script_strings.htm
廣告