一翻旧帖才发现自己以前已经发过了奇葩代码,那就贴两个常规思路的吧,估计会撞车: | @echo off&setlocal enabledelayedexpansion | | set "str=TestABC" | | | | set "str2=!str:~1!" | | set "大写=!str!"&set "小写=!str!" | | | | for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do set "大写=!大写:%%a=%%a!" | | for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do set "小写=!小写:%%a=%%a!" | | | | for /l %%a in (0 1 100) do ( | | if "!str:~%%a,1!"=="!小写:~%%a,1!" ( | | set "str=!str:~,%%a!!大写:~%%a,1!!str2:~%%a!" | | ) else ( | | if "!str:~%%a,1!"=="!大写:~%%a,1!" set "str=!str:~,%%a!!小写:~%%a,1!!str2:~%%a!" | | ) | | ) | | echo !str! | | pauseCOPY |
| @echo off&setlocal enabledelayedexpansion | | set "str=TestABC" | | | | set "str=@!str!" | | for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z)do set %%a=%%a | | | | for /l %%a in (1 1 8189)do ( | | if "!str:~%%a,1!"=="" ( | | for /f "delims=" %%b in (^""!结果!"^")do echo %%~b&pause | | ) | | set 结果=!结果!!str:~%%a,1! | | if !str:~%%a^,1! leq Z if !str:~%%a^,1! geq a ( | | for /f %%b in ("!str:~%%a,1!:") do ( | | if %%b neq %%~db (set chr=%%~db)else set chr=!%%b~0! | | ) | | set 结果=!结果:~,-1!!chr:~,1! | | ) | | )COPY |
|