批处理:FINDSTR 正则表达式不起作用

batch: FINDSTR regular expression not work

echo a.txt| FINDSTR /R ".+\.txt$"

不工作,甚至不工作:

echo a.txt| FINDSTR /R .+\.txt$

为什么?

编辑:

现在可以使用了!

echo a.txt| FINDSTR /R ..*\.txt$

a) Findstr 的正则表达式中没有+。请改用 *..* 应该是 .+ 的正确替代。

b) 行尾前可以有不可见字符,例如如果 | 之前有尾随 space,则由 echo 引起。在行尾之前添加另一个 . 以覆盖它。

C:\> echo a.txt | findstr /r ".*\.txt.$"
a.txt

也可以不用引号。