Search code examples
searchtextformatfindnotepad++

Notepad++ show results of search in one row even when occurs several times in text


I have some Testlog-files and want to check them with notepad ++. E.g. I am looking for the Word ERROR while using "Find all in current document" This gives me a row for each occurrence. But I want only one row per Test of my Testlog-file:

My Testlog-file looks somewhat like that:

Test 111,  Name: ABC, ERROR 3, ERROR 5, ERROR 7, 1.1.22,
Test 222,  Name: xyz, ERROR 26, 1.1.22,
Test 333,  Name: xyz, 1.1.22,
Test 444,  Name: mno, ERROR 32, ERROR 15,  1.1.22,
Test 555,  Name: qwe, 1.1.22,
Test 666,  Name: rtz, 1.1.22,

The result when searching for ERROR -find all in Document I get is:

Test 111,  Name: ABC, ERROR 3, ERROR 5, ERROR 7, 1.1.22,
Test 111,  Name: ABC, ERROR 3, ERROR 5, ERROR 7, 1.1.22,
Test 111,  Name: ABC, ERROR 3, ERROR 5, ERROR 7, 1.1.22,
Test 222,  Name: xyz, ERROR 26, 1.1.22,
Test 444,  Name: mno, ERROR 32, ERROR 15,  1.1.22,
Test 444,  Name: mno, ERROR 32, ERROR 15,  1.1.22,

but I want

Test 111,  Name: ABC, ERROR 3, ERROR 5, ERROR 7, 1.1.22,
Test 222,  Name: xyz, ERROR 26, 1.1.22,
Test 444,  Name: mno, ERROR 32, ERROR 15,  1.1.22,

How can I get only 1 line for each no matter how many Errors I got? There is another post about removing duplicate rows but this does not help


Solution

    • Ctrl+F
    • Find what: (?:.*?ERROR)+
    • TICK Wrap around
    • SELECT Regular expression
    • UNTICK . matches newline
    • Find All in Current Document

    Explanation:

    (?:         # non capture group
        .*?         # 0 or more any character but newline
        ERROR       # the word to be searched
    )+          # end group, must appear 1 or more times
    

    Screenshot:

    enter image description here