Why doesn't this search work?

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
burgundy
Posts: 273
Joined: Fri Oct 16, 2009 9:50 am

Why doesn't this search work?

Post by burgundy »

I want to search for all files or folders on drive X which start with "DT".

I switch regex on and use: x: ^DT but get no results.

When I search using ^DT with regex set on, I get results but, of course, from too many drives. However the results vanish if I type a space before all the "X".

I thought the extra space was causing the problem but x:^DT doesn't give any results either.

How can I make this work?
therube
Posts: 4977
Joined: Thu Sep 03, 2009 6:48 pm

Re: Why doesn't this search work?

Post by therube »

(Without answering your question...)

This should be sufficient (using a "normal" rather then regex search):

Code: Select all

X:  dt*

With regex (without thinking too much about it, presently), you might need to use regex: rather then setting the Search as 'Enable Regex', so...

Code: Select all

X:  regex:^dt
void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: Why doesn't this search work?

Post by void »

therube's answer works well.

With regex enabled, a space will match a space. It is not an AND operator.
When using X: or \\ the full path and filename must match (see Match path when a search term contains a path separator)

With regex enabled, please try searching for:
x:.*\\dt[^\\]*$

x: = forces full path and filename matching
.* = match any character, any number of times.
\\ match a single \
dt = match the letters dt.
[^\\]* match any character (except \\) and number of times.
$ = match the end of the filename.
burgundy
Posts: 273
Joined: Fri Oct 16, 2009 9:50 am

Re: Why doesn't this search work?

Post by burgundy »

therube wrote:This should be sufficient (using a "normal" rather then regex search):

Code: Select all

X:  dt*
Hello Rube. Thanks for your reply. The example above matches the occurence of "DT" anywhere within the file name but I want to find "DT" only at the beginning. Your other suggestion works well.
burgundy
Posts: 273
Joined: Fri Oct 16, 2009 9:50 am

Re: Why doesn't this search work?

Post by burgundy »

void wrote:When using X: or \\ the full path and filename must match (see Match path when a search term contains a path separator)
I had never thought about using the path separator to locate the beginning of a file name. I am not exactly clear what "Match path when a search term contains a path separator" should be enabled in options.

void wrote:With regex enabled, please try searching for:
x:.*\\dt[^\\]*$

x: = forces full path and filename matching
.* = match any character, any number of times.
\\ match a single \
dt = match the letters dt.
[^\\]* match any character (except \\) and number of times.
$ = match the end of the filename.
Thank you for your detailed reply. I can understand the regex up to and including the letters "dt". But immediately after the "dt", why do I need to exclude matching the character "\" ? I guess it's to do with the option mentioned above but I don't really see it.

Also, I am not clear what end of file name character "$" is doing. It seems to be necessary because if I remove the "$", I get an unwanted hit on a file called "descript.ion" within a folder whose full name is "DT".

Thank you.
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Why doesn't this search work?

Post by NotNull »

burgundy wrote: Also, I am not clear what end of file name character "$" is doing. It seems to be necessary because if I remove the "$", I get an unwanted hit on a file called "descript.ion" within a folder whose full name is "DT".
Here is an explanation: viewtopic.php?f=2&t=6551&p=20555&hilit=regex#p20555
void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: Why doesn't this search work?

Post by void »

The dt[^\\]*$ part matches a string with no backslash, eg: the file name part, this will force x:.*\\ to match the whole path.
Without the $, dt could match anywhere in the path part.
Post Reply