Search - dnGrep/dnGrep GitHub Wiki

Specifying file criteria

First the directory needs to be selected in the "Search in" field by clicking browse button, drag and drop a folder onto the dnGrep window, or start from Windows File Explorer.

You can set multiple start folders by separating them with a comma or semicolon: C:\repos\dnGrep;C:\repos\AvalonEdit


Next file filters need to be set.

Filter panel is accessed by clicking on expander button below the "Folder" path. It contains file-based filters including:

  • Filesize - limits files including in search by file size
  • Subfolders - when selected files in subfolders are included in search
  • Max Depth - the maximum depth of folders to search
  • Hidden folders - when selected files in hidden subfolders are included in search
  • Binary files - when selected binary files are included in the search
  • Symbolic links - if the file search should follow symbolic links
  • Date and time range - by file creation time or last modified time
  • Patten type - Regular expression, Wildcard pattern, or Everything (shown if Everything is installed) applies to the "Patterns to match" and "Patterns to exclude" fields.
  • File filter section - to choose a filter file to exclude files by path or pattern
  • Use .gitignore (shown if Git is installed) - excludes files and folders as specified in .gitignore
  • Skip remote cloud storage files - to skip One Drive and similar storage.
  • Search parallel - enables or disables multi-threaded searches.
  • Encoding - can be used to specify file encoding; default value is "Auto detection"

Note: If search pattern is not provided and "Allow searching for file name only" is enabled (see Options), the application will search for filenames only and will not search the file body.

Specifying search criteria

Once the file criteria are specified five search methods become available for file search: regular expression, XPath, plain text, phonetic and byte. Each of these methods has its benefits and drawbacks:

  • Plain text: plain text search is the fastest option however it does not provide the flexibility that regular expressions offer.
  • Regular Expressions: regular-expression search is not as fast as plain-text search, however it allows for the use of patterns and wild-cards
  • XPath: XPath is an XML query language; it will not work with regular non-XML files
  • Phonetic: phonetic search is an approximate search used when exact spelling of a search term is not known
  • Byte: search for a sequence of bytes in binary or text files

In additional to the five methods, additional options are available for some search types: global, case sensitive, multiline, and whole word.

  • Global - when true returns all matches in each file, and when false returns only the first match in each file. Global is not implemented in the .NET regular expression language, so dnGrep has been modified to include it for both Regular Expression and Text searches (it is not used for XPath, Phonetic, or Byte searches). Unchecking Global will stop searching each file after the first match is found. This is useful if you are looking for a particular match with a regular expression. Setting Global to false can make searches much faster if you do not need all the matches.
  • Multiline option allows to match multiple lines in the search pattern.
    When enabled with regular expression mode, Multiline option will be used in regular expressions engine.
  • Match dot as new line option is also available in regular expression mode. Also known as "Singleline", this option treats the whole file as a single string with no line breaks.
  • Boolean operators allow searching for multiple patterns at the same time.
  • Capture group search allows using part of the file name in the search pattern.

Next, enter search pattern in the "Search for" field.

Hint: Use the "Test Expression" button to test out regular-expression patterns.

Performing search

Initial search is performed by clicking "Search" button. Clicking the Search button will perform a full search. The option drop-down will do a search stopping after the first match or pause after five matches. The number of matches to stop or pause is configurable in the Options dialog.

Once the initial search is complete, the "Search in results" check box appears allowing to search within results.
In this mode, only files returned in the previous search will be used for searching.

Working with Search Results

The F3 and Shift+F3 keys will move to the next match and first match in the next file in the results. The F4 and Shift+F4 keys move to the previous match and the last match in the previous file in the results.

Sort the results using the "Sort" button and choosing sort options in the drop-down part of the split button.

Search result tree will show all matched strings highlighted.
Use "Show results in context" property below the results panel or in Options to show several lines above and below the matched line for context.

Hint: Result tree supports dragging file name and matched line directly into a text editor.
Dragging a filename onto a text editor would open the file and dragging matched line would copy the line.

⚠️ **GitHub.com Fallback** ⚠️