Board logo

标题: [文本处理] 批处理命令findstr问题 [打印本页]

作者: Fit    时间: 2021-10-26 12:04     标题: 批处理命令findstr问题

findstr "^[0-9]*$" 2.txt

发现2.txt中有空行,也会显示出来,怎么处理
作者: qixiaobin0715    时间: 2021-10-26 12:05

回复 1# Fit
findstr "^[0-9][0-9]*$" 2.txt
作者: Fit    时间: 2021-10-26 12:07

好的谢谢了!!!!!!!!!!!!!!!!!
作者: Fit    时间: 2021-10-26 12:12

findstr /s "^[a-z][a-z]*$" *.txt
为什么大写也出现?
作者: a20150604    时间: 2021-10-26 12:42

findstr 不是按标准正则设计的, 还是不要玩它的好
  1. findstr /s /r "^[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]*$" *.txt
复制代码
参考:
https://stackoverflow.com/questi ... -some-circumstances

https://stackoverflow.com/questi ... n/20159191#20159191
作者: Batcher    时间: 2021-10-26 13:37

回复 4# Fit


[a-z]和[A-Z]不一定分别代表小写和大写字母
http://bbs.bathome.net/thread-6851-1-1.html
http://bbs.bathome.net/thread-12314-1-1.html
作者: Fit    时间: 2021-10-26 14:09

好的谢谢了
作者: qixiaobin0715    时间: 2021-10-26 15:42

回复 6# Batcher
受教了,原来用findstr表达ASCII字符可以这样['-z]。




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