News:

MultiCommander v16.6 is released!

Main Menu

File find

Started by amenu, September 14, 2015, 06:09:21

Previous topic - Next topic

amenu

I just started using MC and am learning as I go along. I wanted to use file find to find filenames that had both of two words in them -- i.e., word1 and word2, not word1 or word2. I looked in the online documentation but did not see the answer. Where can I find this information.
-- Arthur

Jungle

#1
Probably you should use RegEx like
(.*)(word1)(.*)(word2)(.*)
to search for word1 followed by word2

or
(.*)(word1|word2)(.*)(word2|word1)(.*)
to ignore order

amenu

I am not familiar with RegEx codes. Where is there an instruction manual where I can learn how to use RegEx?
-- Arthur

Jungle

Basic info coud be found here

amenu

I've looked at the Wikipedia article and have a sense of how RegEx works. Would not the second expression you gave:

Code: [Select]
(.*)(word1|word2)(.*)(word2|word1)(.*)

select the files I am looking for (files that have both word1 and word2 in any order in their filenames) but also select files with two occurrences of word1 and no occurrences of word2, or two occurrences of word2 and no occurrences of word1?

I am thinking ((.*)(word1)(.*)(word2)(.*))|((.*)(word2)(.*)(word1)(.*)) would give me just those files that have both word1 and word2 in any order in their filenames.

I am ready to be corrected, as I am obviously unschooled in RegEx.
-- Arthur

Jungle

You're probably right.

Ulfhednar

This is a useful free regex tester
http://antix.co.uk/Projects/Regex-Tester

If you want to go further with Regex this is a good place to look
http://www.regular-expressions.info/jgsoft.html
Some good regex progs as well (but paid-for).

Mathias (Author)

I'm not an expert in RegEx

but this worked for me..  it requires that that word1 and word2 exist in the file in both orders (first word1 and then word2, or word2 and then word1)
Might get messy if more then two is used. But there must be some better regex trick for that

(.*word1.*word2.*|.*word2.*word1.*)