在批处理文件中查找特定字母 [英] find Specific letters in batch file

查看:99
本文介绍了在批处理文件中查找特定字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望批量文件在文件中搜索,如果有小英文字母和数字只会将他发送到fin,如果他的符号不同于小英文字母和数字,它将发送给他结束



例如:



set / p test =输入密码

echo%test%> 123。 txt

findstr / ma,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,1,2,3,4,5,6,7,8,9,0

if%errorlevel%== 0 goto fin

if%errorlevel%== 1 goto end

:fin

echo你的密码有小英文字母和数字

暂停

退出

:结束

回显密码的符号与小英文字母和数字不同

暂停

退出

解决方案

如果查看findstr描述: ^ ]您的代码无法正常工作,甚至无法使用。



findstr的格式为:

 FINDSTR [options] string filename 

您的代码不包含文件,所以它没有什么可以搜索的,它正在寻找'a'上的精确匹配,后跟逗号,后跟一个'b',后跟一个逗号,然后是......



请尝试:

 FINDSTR / m[abcdefghijklmnopqrstuvwxyz0123456789] +123.txt 

我不保证它会起作用,但它比你的版本更有可能! :笑


i want batch file search in file if have small english letters and numbers only it will send him to fin and if he have symbol different than small english letters and numbers it will send him to end

for example:

set /p test=enter password
echo %test%>123.txt
findstr /m "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,1,2,3,4,5,6,7,8,9,0"
if %errorlevel%==0 goto fin
if %errorlevel%==1 goto end
:fin
echo your password have small english letters and numbers
pause
exit
:end
echo your password have symbol different than small english letters and numbers
pause
exit

解决方案

If you look at the findstr description: http://technet.microsoft.com/en-us/library/bb490907.aspx[^] your code is not going to work, or even close to.

The format for findstr is:

FINDSTR [options] string filename

Your code doesn't include the file, so it has nothing to serach, and it is looking for an exact match on an 'a', followed by a comma, followed by a 'b', followed by a comma, followed by...

Instead try:

FINDSTR /m "[abcdefghijklmnopqrstuvwxyz0123456789]+" 123.txt

I don't guarantee it will work, but it stands a better chance than your version! :laugh:


这篇关于在批处理文件中查找特定字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆