Board logo

标题: [文本处理] 字符串合并后删除重复字符串,求实现 [打印本页]

作者: alibabalj    时间: 2014-11-24 09:26     标题: 字符串合并后删除重复字符串,求实现

本帖最后由 alibabalj 于 2014-11-24 09:29 编辑

@echo on
set aaa="c:\;C:\Program Files(86)"
set bbb="C:\Program Files(86);d:\"
for %%i in (%aaa:"=%;%bbb:"=%)do if not defined %%i call set ccc=%%ccc%%;%%i&set %%i=y
set ccc="%ccc:~1%"
echo ccc=%ccc%
pause

我想实现 ccc = "c:\;C:\Program Files(86);d:\"
作者: DAIC    时间: 2014-11-24 10:02

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. set aaa="c:\;C:\Program Files(86)"
  4. set bbb="C:\Program Files(86);d:\"
  5. set aaa=%aaa:;=" "%
  6. set bbb=%bbb:;=" "%
  7. set "ccc="
  8. for %%i in (%aaa% %bbb%) do (
  9.     if not defined %%i (
  10.         set "ccc=%%~i;!ccc!"
  11.         set "%%i=1"
  12.     )
  13. )
  14. set ccc="%ccc:~0,-1%"
  15. echo ccc=%ccc%
  16. pause
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2