Foreword: Recently wrote a bat used to quickly compile SWF to the target directory, want to use the findstr command by matching the target directory name, matching the number of more than 600, found that the match took a long time, about more than 10 seconds, so still give up the character match, obediently spell the full name to locate the directory. It feels like bat is running less efficiently. A little search, see some of the Post also confirms my idea. BAT is not suitable for doing things that are too complicated. or share the usage of the findstr command. Batch run Efficiency discussion post summary findstr regular expression Summary What is a regular expression?
Baidu Http://baike.baidu.com/view/94238.htm?fr=ala0_1#4_5 findstr Regular expression is used to define the string style of the
Its meta characters are., *, [-], \, \<, \>, ^, $, etc.
The main objects involved in the operation are letters, numbers, symbols, and Chinese characters. And the operation has a special rule. FINDSTR Regular Expression Usage rules summary beginning line end rule
such as "^rem", "bat$" means to match REM from the beginning of the line, and to match bat from the end.
0 The end of a line can be English, a number, or a Chinese character. Character Set rules
such as [}>], [ABC], [123], [a-za-z], [0-9] indicate that the row contains any character in the set is a match.
Note that this is a collection, not a string. For example, "[News]" cannot be understood to find rows containing news words, but only to locate a line containing one of the 4 letters of N e W S.
0 It is necessary to note that the set elements in this character set can be letters and numbers and general half-width characters.
If it can be:} {,.] [etc, but double quotes are not recognized, cannot be Chinese characters (Chinese characters are not ASCII code).
0 "[. *]" in the collection. *, as ordinary characters, no special meaning.
0 can be used in combination, such as [aef1-3x-z] means that the character set is the AEF and the number 1-3 and the letter x-z and other elements of the set.
0 "[Ah][1-3]" represents 2 characters. The subtraction rule [^abc] refers to the help information, which should be understood to match a line that does not contain ABC three letters. However, under the XP system, it is not explained correctly.
0 "[^echo.]" actual representation is removed as "echo" in the Find results. The line of the string. Wildcard and recurrence rules
That is. *
0 wildcard characters. Represents any one character, including letters, numbers, half-width symbols, and spaces, but does not include blank lines.
0 Repeat character * represents the repetition of the preceding letter (repeats from 0 to several times). such as. * [a-z]* [0-9]* [abc]* A * word prefix suffix positioning rules
"\<cal" and = "" "ed\=" ">"
The word can be English words and numbers, and the word rule does not apply to Chinese characters. Symbol \ is an escape character.
0 "\<cal" represents a word in the find text that is prefixed with a CAL for words such as = "Call=" "called=" "calling=" "calculation<br=" ">0" ed\> "Find text, English words with Ed suffix words such as called added changed
0 "\<call\>" is used to find words exactly. This is used to find the exact word call, so the calling called is not matched.
0 "\<3389\>" means to find the exact 3389, then 33898, 233895 will not be matched. Keyword rule "string"
The string can be a combination of English words, Chinese characters, numbers, symbols, and the rules above. The only line ending rule, and the rule, can be interpreted correctly for Chinese characters.
Escape character \
Converts special characters (metacharacters) in an expression to ordinary characters. But cannot pair double quotes "and greater than sign > escape.
Common wording
\., \*, \ \, \[, \], \-, \\<
If "\.bat" converts the wildcard character to a normal period, this indicates the batch file name that matches the end of ". Bat". Can also be written as "[.] Bat Example 1:dir/a/b/s d:\ | findstr/i "\.bat$"
0 find the line at the end of the line that is a ". Bat" string and display it.
\ is an escape symbol that makes a period. is no longer a wildcard, but a point in the file extension name. A keyword query for expressions, here is a batch file that enumerates the suffixes that are the bat. dir/a/b/s D:\ | findstr/i ". bat$"
0 effect on dir/a/b/s d:\ | findstr/i "bat$"
No, there's one character difference findstr/r/i/n Google D:\bat\wenben.txt | More
0 use Strings and [drive:][path] filename [...] in the command string, all findstr command-line options must precede Strings and [drive:][path] filename [...]. FINDSTR/R/i/n/x/c: "Google News" D:\bat\htm\meinv.txt | More
0/x prints exactly the rows that match. Find only the lines of the "Google News" word.
If it is a string with spaces, enclose it in double quotation marks, and use the parameter/C: "String1 string2" findstr. 2.txt or Findstr "." 2.txt
0 find any character from file 2.txt, excluding null characters or blank lines.
Null character is not a space: can match spaces
F:>echo hi pz|findstr "... pz"
Hi PZ
F:>echo hi pz|findstr ".... Pz"
findstr/i/n [g-k] d:\bat\htm\meinv.txt | More
0 in the expression [g-k], can be the letter A-Z or the number 0-9, not a Chinese character. and to order, from small to large. Example 2
The following command implements extracting a specific line of a Web page findstr/r/i/n%string%%htmfile%%htmfile% represents a Web page file (a text file).
%string% represents a keyword or string expression. "
Go Summary of findstr Regular expressions