Jump to content
Sign in to follow this  
dummzeuch

Regular expression for "exclude dirs" in Grep?

Recommended Posts

Another thing I just found out is that the Grep expert uses a regular expression for the exclude dirs option.

It first escapes meta characters (e.g. '.', '*', '\' etc.), replaces ';' with '|' and then uses the result as a case insensitive regular expression to match the full directory name and the full file name. Every directory or file that matches the regex is excluded from the search.

 

The help says this:

Exclude Dirs:

A semicolon separated list of directories to exclude from the search
(the exclusion is done via a substring match on the full directory and file name)

I always assumed that this filter is only applied to the name of subdirectories and that it does a full match, e.g. 'src' matches the 'src' subdirectory only, not just any directory name that contains the string 'src', e.g. 'deleted-src'. And I never expected it to match a file name like 'somesrc.pas'.

 

Searching the directory 'd:\src\SomeProject' with an exclude dirs filter of 'src' will actually find nothing at all because all names will start with 'd:\src' which always matches the filter!

 

Did you know that? Is this a bug or a feature?

Edited by dummzeuch

Share this post


Link to post

OK, since nobody bothered to reply, I assume that it won't matter if I change that feature to do what most people will assume it does:

Only search sub-directories that do not match those given in the exclude dirs list.

Share this post


Link to post
3 hours ago, dummzeuch said:

OK, since nobody bothered to reply, I assume that it won't matter if I change that feature to do what most people will assume it does:

Only search sub-directories that do not match those given in the exclude dirs list.

done

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×