简体   繁体   中英

batch: FINDSTR regular expression not work

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

not work and not even:

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

Why?

Edit:

Now works!

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

a) There is no + in the regex of Findstr. Use * instead. ..* should be the correct replacement for .+ .

b) There can be invisible character before the end of the line, eg caused by echo if there's a trailing space before | . Add another . before the line end to cover that.

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

It's also possible without the quotation marks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM