背景
不管学习何种编程语言,何种编程脚本,对字符串的处理都是必备的基础知识之一。本文讲述BAT批处理脚本中如何去掉字符串中的空格。
源码
@echo off
set str_left=" with left space"
set str_right="with right space "
set str_space=" many space "
echo -------------Before strim---------------
echo=
echo %str_left%
echo %str_right%
echo %str_space%
echo=
echo -------------After strim---------------
CALL :StripLeft %str_left%
echo "%G_STRIP_LEFT_RETURN%"
CALL :StripRight %str_right%
echo "%G_STRIP_RIGHT_RETURN%"
CALL :StripLR %str_space%
echo "%G_STRIP_LR_RETURN%"
set strimALL=%str_space: =%
echo %strimALL%
pause
Rem ------------for call function---------
:StripLeft
for /f