
So to find the string snark at the beginning of a line, use ^snark Since FINDSTR also breaks lines after, a simple regex of " ^" will always match all lines within a file, even a binary file. ^ matches beginning of input stream as well as any position immediately following a. * expression can be useful within a larger expression, forĮxample a.*b will match any string beginning with A and ending with B.įINDSTR does not support alternation with the pipe character ( |) multiple Regular Expressions can be separated with spaces, just the same as separating multiple words (assuming you have not specified a literal search with /C) but this might not be useful if the regex itself contains spaces.įINDSTR does not support UTF-16 files, but FIND does. Is similar in effect to the filename wildcard (*.*). Metacharacters are most powerful when they are used together.įor example, the combination of the wildcard character (.) and repeat (*) character \ x Escape: literal use of metacharacter x. Range: any characters within the specified range

Inverse class: any one character NOT in the set. Character class: any one character in the set. * Repeat: zero or more occurances of previous character or class. FINDSTR support for regular expressions is limitedĪnd non-standard, only the following metacharacters are supported. An alternative approach is to chain multiple findstr commands:įINDSTR /ic:"hello" Demo.txt | findstr /ic:"goodbye" Regular Expressions (Search for patterns of text)įINDSTR with the /R option can use the following metacharacters which have special meaning either as an operator or delimiter. To search for more than 2 items in any order starts to become impractical as you would you need every permutation. The following are all equivalent ways of expressing a case insensitive regex search for any line that contains both "hello" and "goodbye" in any orderįINDSTR /i /r /c:"hello.*goodbye" /c:"goodbye.*hello" Demo.txtįINDSTR -i -r -c:"hello.*goodbye" /c:"goodbye.*hello" Demo.txtįINDSTR /irc:"hello.*goodbye" /c:"goodbye.*hello" Demo.txt However, the concatenated option list can contain at most one multicharacter option such as OFF or F:, and the multi-character option must be the last option in the list. Options can also be concatenated after a single / or. Options can be prefixed with either / or. To match an entire phrase/sentence or to use Regular Expressions use the /C and /R options. The default behaviour of FINDSTR is to match any word, so FINDSTR "blue planet" will match the word blue or the word planet. If more than one file is searched (/F), the results will be prefixed with the filename where the text was found. When using /G or /F the text file should be a plain ANSI text file with one Search string or Filename/Path on each line. O Print character offset before each matching line. M Print only the filename if a file contains a match. N Print the line number before each line that matches. V Print only lines that do NOT contain a match. E Match pattern if at the END of a line. B Match pattern if at the Beginning of a line.
CMD FIND FILE CONTAINING STRING OFFLINE
OFF Do not skip files with the OffLine attribute set.


P Skip any file that contains non-printable characters Options can be any combination of the following switches: A: color Display filenames in colour (2 hex digits) d: dirlist Search a comma-delimited list of directories. F: file Get a list of filename(s) to search from a file (/ stands for console). G: StringsFile Get search string from a file (/ stands for console). R /C: string Use string as a regular expression.

C: string Use string as a literal search string (may include spaces). String(s) Text to search for, each word a separate search. Search for a text string in a file (or multiple files) unlike the simple FIND command FINDSTR supports more complex regular expressions.
