How to find lines after two ore more words in file

Hi

I want to find lines in file which contain two or more given words. For example I want to find all lines in the file that contains both ‘file:’ and ‘path:’ keywords. For example line: " file: create: open: path: …" contains both ‘file:’ and ‘path:’ keywords. This things simplify a lot the process of searching in a structured document.
Can somebody help me with a simple idea?

Technically, you won’t find “lines” but occurrences of a pattern. If your sequence has a fixed pattern, i.e. the order of the keywords is known, you can do with a regular expression in Edit>Find & Replace.

Something like file:.*path: will locate the sequence.

You need another regexp for the reverse order of your keywords.

@ghegheg,
Each line is a new paragraph? You need only to count them, or apply some style, replace it, etc.?

Or: file:.*path:|path:.*file:

The solution ‘file:.*path:’ doesn’t work anyhow. I tried it without any success! Nor the other solution ‘file:.*path: | path:.*file:’ doesn’t work.
The keywords ‘file:’, ‘path:’, ‘type:’, ‘string:’ are situated at the beginning of the paragraph. Every paragraph starts with some keywords. I need only find paragraphs which start with some specific words for example ‘file:’ and ‘path:’ in my example.

Did you remember to click on Other Options and make sure Regular Expressions is selected in the Find and Replace dialog?

FYI: LibreOffice uses ICU RegExp, which are different from the Perl-RegExp syntax commonly used in many other software products: Regular Expressions - ICU Documentation. Just if you try examples (like group references), which produce errors. The basic syntax is the same, so the examples from the other comments look fine to me.

Yes, It works, thank you very much.

Although, the search technique could be improved. It’s about time. You must open Find Replace, check Regular expression and type: key1 .* key2 | key2 .* key1, that’s consume valuable time. It would be easier to type ‘key1 + (certain sign) + key2’ in find text box (that is more accessible) to search all combinations of words key1 key2 or key2 key1 situated into a sentence in file. For example you have an catalog and you must find quickly for many times something after keywords.

Ok, thank you very much for help.

You mention in a previous comment that the keyword is at line beginning. The regexp can be simplified to ^keyword: or ^(file|path|type):.

You can even reduce to ^[:alpha:]+?: to locate the next keyword, no matter which it is.

To make your life easier, save this regexp somewhere and paste it into the Finf & Replace dialog instead of typing it.