1. Findstr. 2. TXT or findstr “.” 2. TXT
Look for any character from the file 2. TXT, excluding empty characters or lines
2. Findstr. * 2.txt or findstr “. *” 2.txt
Find any character from the file 2. TXT, including empty line and empty character
3.findstr “[0-9]” 2.txt
Look up a string or line containing the numbers 0-9 from the file 2.txt
4.findstr “[a-zA-Z]” 2.txt
Find a string or line containing any character from the file 2. TXT
5.findstr “[abcezy]” 2.txt
Find a string or line containing a b c e Z Y letters from the file 2.txt
6.findstr “[a-fl-z]” 2.txt
Look up the string of lowercase characters A-F L-Z from the file 2.txt, but it does not contain the letters g h I j K.
7.findstr “M[abc][hig]Y” 2.txt
From the file 2. TXT, you can match mahy, mbiy, mahy, etc ..
8. Application of ^ and $symbols
^Indicates the beginning of the line, and “^ step” only matches the first word in “step Hello world”
$means the end of the line, and “step $” only matches the last word in “Hello world step”
9.finstr “[^0-9]” 2.txt
If it is a string or line of pure numbers, it will be filtered out. For example, if it is a string like 2323423, it will not be in the form of 345hh888.
10.findstr “[^a-z]” 2.txt
As above, if it is a pure alphabetic string or line, it will be filtered out, such as sdlfjlkjlksjdklfjlskdf. If it is in the form of sdfksjdkf99999, it will not be mixed with numbers
11. The role of
It has been said before that “. *” indicates that the search condition is any character. The * sign is not used for any character in regular expressions, but for the number of repetitions of the left character or expression. The * sign indicates that the number of repetitions is zero or more.
12.findstr “^[0-9]*$” 2.txt
This is a pure number found by matching, for example, 234. If it is 2133334kkjl234, it will be filtered out.
Findstr “^[a-z]*$” 2.txt
This is a pure letter found by matching, such as sdfsdf sdfsdf. If it is 213sldjfkljsdlk, it will be filtered out
If there is no * sign in the search criteria, that is, do not repeat the search criteria on the left, i.e. [0-9] [A-Z], then only the first character of the string can be matched, because there are restrictions on the beginning and end of the line. If the first character of “^ [0-9] $” is a number, it will be matched, if it is not, it will be filtered out, if the string is 9 Just match. If it’s 98 or 9j, it’s not OK.
13. “\<… \>”What does this expression do
This means to find a string exactly, \ < SSS means the beginning of the word, SSS \ > means the end of the word
Echo Hello world computer | findstr “\ < Computer \ >”
Echo Hello world computer | findstr “\ < Computer \ >” is not a good form. What he is looking for is the string “computer”, so he can’t.
Echo Hello world computer | findstr “. * computer \ >” so you can match