|
|
发表于 2009-3-27 22:50:07
|
显示全部楼层
- @echo off
- rem 限制输入3位至10位字母
- set LenMin=3
- set LenMax=10
- set AllLetter=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
- :GetInput
- set input=
- set /p "input=请输入3至10位字母:"
- if "%input%" neq "" (
- if "%input:~2,1%" equ "" (
- echo 不足%LenMin%位
- goto :GetInput
- ) else if "%input:~10,1%" neq "" (
- echo 多于%LenMax%位
- goto :GetInput
- )
- ) else (
- echo 输入不能为空
- goto :GetInput
- )
- setlocal enabledelayedexpansion
- for %%a in (%AllLetter%) do (
- set input=!input:%%a=!
- if "!input!" equ "" (
- goto :RightInput
- )
- )
- if "!input!" neq "" (
- echo 只能输入纯字母[a-zA-Z]
- endlocal
- goto :GetInput
- )
- :RightInput
- echo 恭喜输入正确
- pause
复制代码
[ 本帖最后由 Batcher 于 2009-3-29 14:20 编辑 ] |
评分
-
查看全部评分
|