3

I have done a multi-line find regex using Notepad++. The line begins with INFO and ends with a known digit pattern. When I click find after typing my regex, I get the correct results highlighted in the main window.

For my use case, I want to do find all in open documents using this same regex. The problem is when I do it, the find results window only shows the first line of the multi-line match. To be truly useful, I need the entire match (which in my case turns out to be 2 lines nearly all the time) displayed in the find results window. I wish to take the output of the find results screen and use it as input to another process which is beyond the scope of this question.

So how do I display the entire multi-line match. I can think of how to do this as a program in a scripting or programming language, but how can I do this from within Notepad++?

9
  • Can you provide the regex you are already using by chance? Aug 22, 2017 at 0:06
  • 1
    If the same regex works in one part of Notepad++ and not the other, it's probably just a bug in Notepad++, and nothing we can help you with. You should file a bug in their issue tracker.
    – Patches
    Aug 28, 2017 at 2:01
  • 1
    Notepad++ is pretty reliable, so I think you should post a test-case of 2 example documents and the regex find-string in question, in order to demonstrate the problem. If this is a bug, you will need in any case this example for posting a bug report, so you might as well demonstrate it here first.
    – harrymc
    Jun 20, 2019 at 5:47
  • @harrymc I don't think it's a bug; it's either a feature that's not obvious how to use, or it's not possible based on the current design.
    – Stobor
    Jun 26, 2019 at 2:56
  • @Stobor: The stated problem is very unclear. Notepad++ multi-line search works reliably and selects the entire multi-line text. Without an example your problem stays incomprehensible.
    – harrymc
    Jun 26, 2019 at 6:07

5 Answers 5

7
+25

Negative answer: While it is possible to search for and select multiple lines in multiple files by setting the regex option ". matches newline", the Find Results pane will only list the first line per found result.

This behavior is built into Notepad++ and cannot be changed. I have also looked at the listed plugins, and none of them can change it.

You could ask for this as a feature request on the Notepad++ Community, but I cannot see any immediate solution for your problem.

1

Try the following. Let's say your document starts with the word INFO and ends with 999.

Your regex would be:

INFO.+?999

In order for this to work with MULTI LINES, in the search window, right next to the tick for using Regular expression, there's a checkbox that says . matches newline. You need to have it selected for it to work.

p.s. Checked that it works on my Notepad++ version 7.5.1

p.s.2 The find only returns the 1st line of each occurrence. So if your match starts at line 5, but ends in line 10, it will display on the search window that it starts at line 5. You can't change that behavior in the application.

1
  • Hi Luis - I think your p.s.2 gets to the thing being asked for. In my case, I'm after a way to show all of lines 5 through 10 in the search window.
    – Stobor
    Jun 26, 2019 at 2:58
0

Managed to solve it in two steps: first step:

  • match multiline
  • replace it with some mark and keep useful information second step:
  • "find in document" = look for marked lines [enter image description here][1]

[1]: see working sample https://i.sstatic.net/ClQjU.png

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jan 31, 2022 at 19:14
0

You can use regular expression's assertions. E.g.: for this text:

Non-interesting 1st line
 Non-interesting begin of 2nd line: Wow
...
(?<=Non-interesting 1st line\r\n Non-interesting begin of 2nd line: )[^\r\n]*

It would show:

Search "(?<=Non-interesting 1st line\r\n Non-interesting begin of 2nd line: )[^\r\n]*" (1 hit in 1 file of 1 searched)
  new 9 (1 hit)
    Line 2:  Non-interesting begin of 2nd line: Wow
1
  • 1
    This doesn't answer the question, OP wants to display multilines in the search result window.
    – Toto
    Jul 27, 2022 at 11:33
0

There is a hackish way to accomplish this.

  1. In the find dialog box, go to the mark tab.
  2. Click on Mark All
  3. Now click on Copy marked text
  4. Open a new tab, and then paste the copied text

Now you will have all the lines of each search result match displayed, just that it will not be in the Search results window. Another drawback is that this will work only on the current document, your requirement to Find All in All Opened Documents wont be met.

notepad+++ find dialog: Copy marked text

The following gif shows performing these steps on a zookeeper log (link).

notepad++ multiline search output

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .