- @echo off
- color 1a
- echo.=============================================================
- echo.
- echo. Eample of "For...in...do.."
- echo.
- echo.set str=I love,bbs;bathome.net
- echo.A1:Print "I"、"love"、"bbs"、"bathome" and "cn" respectively.
- echo.A2:Only to print "cn"
- echo.
- echo.=============================================================
- set str=I love;bbs;bathome.net
- echo.Here is the answer of A1 (Using Switch of "/f"):
- for /f "tokens=1-5 delims=;. " %%a in ("%str%") do (echo %%a & echo %%b & echo %%c & echo %%d & echo %%e )
- echo.===========================================
- echo.Here is the answer of A2:
- set str=I love;bbs;bathome.net
- for /f "tokens=5 delims=;. " %%a in ("%str%") do (echo %%a )
- echo.===========================================
- set str=I love;bbs;bathome.net
- echo.Here is the answer of A1 (No Using Switch of "/f"):
- for %%a in (%str%) do (echo %%a)
- set /p over=
复制代码
|