Search code examples
regexfindnotepad++

Compact syntax to exclude file extensions from search


Basically I wonder if there's a shorter way to do this:

*.* !*.exe !*.zip !*.jar

Problem is, I write software that generates files with extensions I can't predict - neither in what I want to exclude, nor include, so my only option is to append exclusions as I go. But my list's length now exceeds N++'s limit, so I wonder if it can be shorter, like

*.* !*.[exe zip jar]

Solution

  • No:

    The Filters list is a space-separated list of wildcard expressions that cmd.exe can understand, like *.doc foo.*.

    • Wildcards can include * for zero or more of any character, and ? for exactly one of any character.

    • Most characters work as literals. However, space is used as the separator, and thus cannot be used as a literal in your filter. Some punctuation characters have special meanings (like the ? and * wildcards, or the ! exclusion or !+\ for recursive exclusion), and cannot be used as literals. Also, the ; causes problems, so even though Microsoft allows it in file and path names, using a ; in the Filters box will not work as you might hope. If you want to match a space or a semicolon ; or other problematic-punctuation in your file or folder for your Filter (whether for inclusion or exclusion), then use the * and/or ? wildcards instead. (So x?y.txt will match the file x;y.txt or x y.txt (with a space between x and y).) And sorry, no, you cannot use quotes around a path-with-spaces to allow the spaces to work as literals: the space is a separator in this field.

    That's because it's simply not a regular expression. Just like the command line/prompt only knows wildcards, not regular expressions, and also no mix of both (f.e. using square brackets). Likewise "Directory" cannot be used with a regex either.