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?
Why doesn't this search work?
Re: Why doesn't this search work?
(Without answering your question...)
This should be sufficient (using a "normal" rather then regex search):
With regex (without thinking too much about it, presently), you might need to use regex: rather then setting the Search as 'Enable Regex', so...
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
Re: Why doesn't this search work?
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.
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.
Re: Why doesn't this search work?
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.therube wrote:This should be sufficient (using a "normal" rather then regex search):Code: Select all
X: dt*
Re: Why doesn't this search work?
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:When using X: or \\ the full path and filename must match (see Match path when a search term contains a path separator)
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.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.
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.
Re: Why doesn't this search work?
Here is an explanation: viewtopic.php?f=2&t=6551&p=20555&hilit=regex#p20555burgundy 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".
Re: Why doesn't this search work?
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.
Without the $, dt could match anywhere in the path part.