How to search files for two words in the same line

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
wanderer
Power Member
Power Member
Posts: 1575
Joined: 2003-03-28, 14:35 UTC
Location: Sol

How to search files for two words in the same line

Post by *wanderer »

I want to search a tree structure for any TEXT file that contains two specific words but they must be in the same line. Is there a way to achieve that using "Find files" dialog?

EDIT: I have had this need in the past too, so if it's not directly supported, i would like to add it as a wish.
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3
x64: Clients/Servers from Win7 to Win11 and Win2K12Srv to Win2K22Srv, mainly Win10 though.
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: How to search files for two words in the same line

Post by *Hacker »

wanderer,
Well, regex is limited to one line, so you can do

Code: Select all

word1.*word2
and then

Code: Select all

word2.*word1
If there was a tc.content field, one could chain them using OR, alas, I am not aware of a WDX which would simply return the content of a file.

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
wanderer
Power Member
Power Member
Posts: 1575
Joined: 2003-03-28, 14:35 UTC
Location: Sol

Re: How to search files for two words in the same line

Post by *wanderer »

Just tried it. Many thanks Hacker, it worked fine. And it also works the same way in the Lister!
Last edited by wanderer on 2021-11-19, 14:47 UTC, edited 1 time in total.
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3
x64: Clients/Servers from Win7 to Win11 and Win2K12Srv to Win2K22Srv, mainly Win10 though.
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: How to search files for two words in the same line

Post by *nsp »

Code: Select all

word1.*word2
in RegExp will match word1 and then word2 the order is taken into account.
If you want to match word2 then word1 you will have to also add the expression like :

Code: Select all

(word1.*word2)|(word2.*word1) 
With pcre you can use multiple lookahead but library inside TC is not as advanced :(
User avatar
wanderer
Power Member
Power Member
Posts: 1575
Joined: 2003-03-28, 14:35 UTC
Location: Sol

Re: How to search files for two words in the same line

Post by *wanderer »

Well, my case was 1-way only (word1.*word2) but thanks for the OR reminder nsp.
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3
x64: Clients/Servers from Win7 to Win11 and Win2K12Srv to Win2K22Srv, mainly Win10 though.
Post Reply