批处理分割字符串

使用for和goto实现分割字符串

set tmpStr=a,b,c

:Loop
	for /f "tokens=1,* delims=," %%a in ("%tmpStr%") do (
		echo %%a
		set tmpStr=%%b
	)
	if "%tmpStr%" EQU "" (
		goto End
	)
	goto Loop
:End

输出结果

a
b
c
posted @ 2020-06-12 10:59  Kyle023  阅读(721)  评论(0)    收藏  举报