[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程批处理在线视频分享
返回列表 发帖
题目更改后很简单。
A1:
@echo off
set str=I love,bbs;bathome=net
for %%I in (%str%) do  echo "%%I"
pause

A2:
@echo off
set str=I love,bbs;bathome=net
for %%i in (%str%) do if %%i==net echo %%i
pause



最初的题目(条件str=I love,bbs;bathhome.net),难度高。

TOP

回复 13# qpzlsn


   你设置了STR变量就可以直接引用了啊

TOP

A1:
  1. @echo off
  2. set str=I love,bbs;bathome=net
  3. for %%i in (%str%) do echo %%i
  4. pause
复制代码
A2:
  1. @echo off
  2. set str=I love,bbs;bathome=net
  3. for %%i in (%str%) do set var=%%i
  4. echo %var%
  5. pause
复制代码

TOP

回复 1# namejm


    A1:
  1. @echo off
  2. set "str=I love,bbs;bathome.net"
  3. for /f "tokens=1,2,3,4,5 delims=,;. " %%a in ("%str%") do (
  4. echo,%%a
  5. echo,%%b
  6. echo,%%c
  7. echo,%%d
  8. echo,%%e)
  9. pause>nul
复制代码
A2:
  1. @echo off
  2. set "str=I love,bbs;bathome.net"
  3. for /f "tokens=1,2,3,4,5 delims=,;. " %%a in ("%str%") do (
  4. echo,%%e)
  5. pause>nul
复制代码

TOP

A1:
@echo off
echo 分隔符1:逗号
for %%i in (I,LOVE,BBS,BATHOME,NET) do echo %%i
echo ____________________________________________
echo 分隔符2:分号
for %%i in (I;LOVE;BBS;BATHOME;NET) do echo %%i
echo ____________________________________________
echo 分隔符3:等号
for %%i in (I=LOVE=BBS=BATHOME=NET) do echo %%i
echo ____________________________________________
echo 分隔符4:跳格键
for %%i in (I        LOVE        BBS        BATHOME        NET) do echo %%i
echo ____________________________________________
echo 分隔符5:空格
for %%i in (I LOVE BBS BATHOME NET) do echo %%i
echo ____________________________________________
echo 非分隔符:点
for %%i in (I.LOVE.BBS.BATHOME.NET) do echo %%i
echo ____________________________________________
pause

A2:
@echo off
set str=I,LOVE,BBS,BATHOME,NET
for %%i in (%str%) do (set a=%%i)
echo %a%
pause

TOP

回复 12# akiraakito


    这位老兄理解地好。谢谢

TOP

返回列表