TO 6
This is the FINDSTR usage info I collected. It's very helpful, let's learn it together!~
Basic usage of FINDSTR regular expressions
Code:
1.findstr . 2.txt or Findstr "." 2.txt
Search for any character in file 2.txt, excluding null characters or blank lines
====================
2.findstr .* 2.txt or findstr ".*" 2.txt
Search for any character in file 2.txt, including blank lines and null characters
====================
3.findstr "" 2.txt
Search in file 2.txt for strings or lines containing digits 0-9
====================
4.findstr "" 2.txt
Search in file 2.txt for strings or lines containing any letters
====================
5.findstr "" 2.txt
Search in file 2.txt for strings or lines containing the letters a b c e z y
====================
6.findstr "" 2.txt
Search in file 2.txt for strings containing lowercase characters a-f and l-z, but not the letters g h I j k.
====================
7.findstr "MY" 2.txt
In file 2.txt it can match MahY, MbiY, MahY, etc.....
====================
8. The use of the symbols ^ and $
^ indicates the beginning of a line, "^step" only matches the first word in "step hello world"
$ indicates the end of a line, "step$" only matches the last word in "hello world step"
====================
9.finstr "" 2.txt
If it is a purely numeric string or line, then it will be filtered out, for example a string like 2323423423. But if it is in a form like 345hh888 then it won't work.
====================
10.findstr "" 2.txt
Same as above, if it is a purely alphabetic string or line, then it will be filtered out, for example characters like sdlfjlkjlksjdklfjlskdf. But if it is in a form like sdfksjdkf99999, mixed with digits, then it won't work.
====================
11.The role of the * sign
As already mentioned above, ".*" means the search condition is any character. The role of * in regular expressions is not any character, but indicates the repetition count of the character or expression on the left side. * indicates the repetition count is zero or more times.
====================
12.findstr "^*$" 2.txt
This matches purely numeric text that is found, for example 234234234234. If it is 2133234kkjl234 then it gets filtered out.
Findstr "^*$" 2.txt
This matches purely alphabetic text that is found, for example sdfsdfsdfsdf. If it is 213sldjfkljsdlk then it gets filtered out.
If there is no * sign in the search condition, that means the search condition on the left side is not repeated, that is , then it can only match the first character of the string, and only this one character, because there is the restriction of beginning and end of line. With "^$", if the first character is a digit then it matches, if not then it is filtered out. If the string is 9 then it matches, but if it is 98 or 9j and the like then it won't work.
=====================
13. The role of the "\<…\>" expression
This means searching exactly for a string. \<sss indicates the starting position of the word, and sss\> indicates the ending position of the word.
echo hello world computer|findstr "\<computer\>" works in this form
echo hello worldcomputer|findstr "\<computer\>" in this form won't work. What it wants to find is the string "computer", so that won't do.
echo hello worldcomputer|findstr ".*computer\>" this way it can match
心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^