Search multiple strings in all opened files



  • Hello, please help me to write a regular expression to search.
    I need to get two search results: first result from “credit” to “payout” and remove all between this lines, second result from “credit” to “stacker” and remove all between this lines.

    Here is example of results:
    First result:

    [19:44:42][Info][]: Credit 50,00
    [19:44:45][Info][]: Note stored (payout)
    

    Second result:

    [19:44:59][Info][]: Credit 100,00
    [19:45:02][Info][]: Note stacked (stacker)
    

    Here is full Log file:

    [19:44:42][Info][]: Credit 50,00
    [19:44:43][Info][]: Note routing successful (10,00 RUB to cashbox)
    [19:44:43][Info][]: Note routing successful (50,00 RUB to storage)
    [19:44:43][Info][]: Note routing successful (100,00 RUB to cashbox)
    [19:44:43][Info][]: Note routing successful (500,00 RUB to storage)
    [19:44:43][Info][]: Note routing successful (1000,00 RUB to cashbox)
    [19:44:43][Info][]: Note routing successful (5000,00 RUB to cashbox)
    [19:44:43][Info][]: Note routing successful (2000,00 RUB to cashbox)
    [19:44:44][Info][]: Note routing successful (200,00 RUB to cashbox)
    [19:44:45][Info][]: Note stored (payout)
    [19:44:55][Payment][]: Reading note
    [19:44:57][Info][]: Note in escrow, amount: 100,00
    [19:44:57][Payment][]: Stacking note
    [19:44:59][Info][]: Credit 100,00
    [19:45:00][Info][]: Note routing successful (10,00 RUB to cashbox)
    [19:45:00][Info][]: Note routing successful (50,00 RUB to storage)
    [19:45:00][Info][]: Note routing successful (100,00 RUB to cashbox)
    [19:45:00][Info][]: Note routing successful (500,00 RUB to storage)
    [19:45:00][Info][]: Note routing successful (1000,00 RUB to cashbox)
    [19:45:00][Info][]: Note routing successful (5000,00 RUB to cashbox)
    [19:45:00][Info][]: Note routing successful (2000,00 RUB to cashbox)
    [19:45:00][Info][]: Note routing successful (200,00 RUB to cashbox)
    [19:45:02][Info][]: Note stacked (stacker)
    [19:45:08][Payment][]: Reading note
    [19:45:10][Info][]: Note in escrow, amount: 50,00
    [19:45:11][Payment][]: Stacking note
    [19:45:15][Info][]: Credit 50,00
    [19:45:16][Info][]: Note routing successful (10,00 RUB to cashbox)
    [19:45:16][Info][]: Note routing successful (50,00 RUB to storage)
    [19:45:16][Info][]: Note routing successful (100,00 RUB to cashbox)
    [19:45:16][Info][]: Note routing successful (500,00 RUB to storage)
    [19:45:16][Info][]: Note routing successful (1000,00 RUB to cashbox)
    [19:45:16][Info][]: Note routing successful (5000,00 RUB to cashbox)
    [19:45:17][Info][]: Note routing successful (2000,00 RUB to cashbox)
    [19:45:17][Info][]: Note routing successful (200,00 RUB to cashbox)
    [19:45:18][Info][]: Note stacked (stacker)
    

    Thanks a lot



  • @Сергей-Бычков said in Search multiple strings in all opened files:

    I need to get two search results: first result from “credit” to “payout” and remove all between this lines, second result from “credit” to “stacker” and remove all between this lines.

    I think I have an answer, however it’s not clear from your question as to whether you JUST want the 3 lines with “Credit”, “(payout)” and “(stacker)” and therefore remove ALL other lines, OR ONLY remove the lines between “Credit” AND “(payout)”, and “Credit” and “(stacker)”. Meaning leave the lines after “(payout)” or “(stacker)” until the next “Credit” line.

    My solution will mark only the 3 lines and the you can remove ALL other lines. So test it and see if that suits your requirements.

    Use the “Mark” function and the following regex:
    (?-i)Credit|\((payout|stacker)\)
    Tick the “bookmark line” and then click “Mark All”. Afterwards you can “remove unmarked lines” using this option under Search, Bookmark.

    Terry



  • Thank you! It works
    Now it looks like this. But now I need to count how much notes stacked to stacker and how much notes stored to payout in about ~20 log files so i need to detach credit+stacked(stacker) lines and credit+stored(payout)

    [14:40:15][Info][]: Credit 100,00
    [14:40:19][Info][]: Note stacked (stacker)
    [14:40:21][Info][]: Credit 100,00
    [14:40:24][Info][]: Note stacked (stacker)
    [14:40:27][Info][]: Credit 100,00
    [14:40:29][Info][]: Note stacked (stacker)
    [15:02:16][Info][]: Credit 500,00
    [15:02:20][Info][]: Note stored (payout)
    [16:53:08][Info][]: Credit 200,00
    [16:53:11][Info][]: Note stacked (stacker)
    [16:53:33][Info][]: Credit 100,00
    [16:53:35][Info][]: Note stacked (stacker)
    [17:45:07][Info][]: Credit 200,00
    [17:45:11][Info][]: Note stacked (stacker)
    [17:45:13][Info][]: Credit 200,00
    [17:45:16][Info][]: Note stacked (stacker)
    [17:45:56][Info][]: Credit 50,00
    [17:45:59][Info][]: Note stacked (stacker)
    [18:34:03][Info][]: Credit 100,00
    [18:34:05][Info][]: Note stacked (stacker)
    [18:34:08][Info][]: Credit 100,00
    [18:34:12][Info][]: Note stacked (stacker)
    [18:34:15][Info][]: Credit 50,00
    [18:34:18][Info][]: Note stacked (stacker)
    [19:44:11][Info][]: Credit 100,00
    [19:44:14][Info][]: Note stacked (stacker)
    [19:44:22][Info][]: Credit 50,00
    [19:44:25][Info][]: Note stacked (stacker)
    [19:44:29][Info][]: Credit 1000,00
    [19:44:31][Info][]: Note stacked (stacker)
    [19:44:42][Info][]: Credit 50,00
    [19:44:45][Info][]: Note stored (payout)
    


  • @Сергей-Бычков

    Why don’t you ask your question in the context of something you’ve already tried that has not done what you thought it would do?

    Your phrasing to this point seems like you want someone to do all of your thinking for you and hand-deliver the solution all bundled up nicely.

    We’re about providing help here to get someone over a hurdle, not really to deliver packaged solutions.



  • @Alan-Kilborn Hello. Just because its hard to write in English to me. Of course I already tried many different ways and about 3 hours in google. But in regular expressions im newbie. I tried to mark this lines but not successful

    ...........Info.....Credit([\s\S]*?)cashbox.
    
    (?-s)^.+\R(?=.*cashbox)|\G.+
    


  • Thanks to all for help
    From that result its easier to do
    It seems I founded a similar situation in this topic
    https://community.notepad-plus-plus.org/topic/16701/how-to-mark-lines-above-marked-lines/5



  • Hello, @сергей-бычков, @alan-kilborn, @terry-r and All,

    Here is a solution, with two regex S/R and a sort !

    I assume that no tabulation char \t exists in your text


    From your initial text file :

    [14:40:15][Info][]: Credit 100,00
    [14:40:19][Info][]: Note stacked (stacker)
    [14:40:21][Info][]: Credit 100,00
    [14:40:24][Info][]: Note stacked (stacker)
    [14:40:27][Info][]: Credit 100,00
    [14:40:29][Info][]: Note stacked (stacker)
    [15:02:16][Info][]: Credit 500,00
    [15:02:20][Info][]: Note stored (payout)
    [16:53:08][Info][]: Credit 200,00
    [16:53:11][Info][]: Note stacked (stacker)
    [16:53:33][Info][]: Credit 100,00
    [16:53:35][Info][]: Note stacked (stacker)
    [17:45:07][Info][]: Credit 200,00
    [17:45:11][Info][]: Note stacked (stacker)
    [17:45:13][Info][]: Credit 200,00
    [17:45:16][Info][]: Note stacked (stacker)
    [17:45:56][Info][]: Credit 50,00
    [17:45:59][Info][]: Note stacked (stacker)
    [18:34:03][Info][]: Credit 100,00
    [18:34:05][Info][]: Note stacked (stacker)
    [18:34:08][Info][]: Credit 100,00
    [18:34:12][Info][]: Note stacked (stacker)
    [18:34:15][Info][]: Credit 50,00
    [18:34:18][Info][]: Note stacked (stacker)
    [19:44:11][Info][]: Credit 100,00
    [19:44:14][Info][]: Note stacked (stacker)
    [19:44:22][Info][]: Credit 50,00
    [19:44:25][Info][]: Note stacked (stacker)
    [19:44:29][Info][]: Credit 1000,00
    [19:44:31][Info][]: Note stacked (stacker)
    [19:44:42][Info][]: Credit 50,00
    [19:44:45][Info][]: Note stored (payout)
    

    Using the following regex S/R

    SEARCH (?-is)^(.+)\R(.+(?:(stacker)|payout).+)

    REPLACE (?3S:P)\2\t\1

    You should get this output text :

    S[14:40:19][Info][]: Note stacked (stacker)	[14:40:15][Info][]: Credit 100,00
    S[14:40:24][Info][]: Note stacked (stacker)	[14:40:21][Info][]: Credit 100,00
    S[14:40:29][Info][]: Note stacked (stacker)	[14:40:27][Info][]: Credit 100,00
    P[15:02:20][Info][]: Note stored (payout)	[15:02:16][Info][]: Credit 500,00
    S[16:53:11][Info][]: Note stacked (stacker)	[16:53:08][Info][]: Credit 200,00
    S[16:53:35][Info][]: Note stacked (stacker)	[16:53:33][Info][]: Credit 100,00
    S[17:45:11][Info][]: Note stacked (stacker)	[17:45:07][Info][]: Credit 200,00
    S[17:45:16][Info][]: Note stacked (stacker)	[17:45:13][Info][]: Credit 200,00
    S[17:45:59][Info][]: Note stacked (stacker)	[17:45:56][Info][]: Credit 50,00
    S[18:34:05][Info][]: Note stacked (stacker)	[18:34:03][Info][]: Credit 100,00
    S[18:34:12][Info][]: Note stacked (stacker)	[18:34:08][Info][]: Credit 100,00
    S[18:34:18][Info][]: Note stacked (stacker)	[18:34:15][Info][]: Credit 50,00
    S[19:44:14][Info][]: Note stacked (stacker)	[19:44:11][Info][]: Credit 100,00
    S[19:44:25][Info][]: Note stacked (stacker)	[19:44:22][Info][]: Credit 50,00
    S[19:44:31][Info][]: Note stacked (stacker)	[19:44:29][Info][]: Credit 1000,00
    P[19:44:45][Info][]: Note stored (payout)	[19:44:42][Info][]: Credit 50,00
    

    You’ll notice :

    • Two consecutive lines have been swapped and placed in a same line

    • A first character is added : S for stacker OR P for payout

    • The separator between these two lines is a tabulation char ( \t ), in order that all the times are aligned


    Now, perform a usual sort with the command :

    Edit > Line Operations > Sort Lines Lexicographically Ascending

    We now get the sorted text, below, with lines concerning payout coming first and, for each block ( P and S ), lines are sorted by time, too

    P[15:02:20][Info][]: Note stored (payout)	[15:02:16][Info][]: Credit 500,00
    P[19:44:45][Info][]: Note stored (payout)	[19:44:42][Info][]: Credit 50,00
    S[14:40:19][Info][]: Note stacked (stacker)	[14:40:15][Info][]: Credit 100,00
    S[14:40:24][Info][]: Note stacked (stacker)	[14:40:21][Info][]: Credit 100,00
    S[14:40:29][Info][]: Note stacked (stacker)	[14:40:27][Info][]: Credit 100,00
    S[16:53:11][Info][]: Note stacked (stacker)	[16:53:08][Info][]: Credit 200,00
    S[16:53:35][Info][]: Note stacked (stacker)	[16:53:33][Info][]: Credit 100,00
    S[17:45:11][Info][]: Note stacked (stacker)	[17:45:07][Info][]: Credit 200,00
    S[17:45:16][Info][]: Note stacked (stacker)	[17:45:13][Info][]: Credit 200,00
    S[17:45:59][Info][]: Note stacked (stacker)	[17:45:56][Info][]: Credit 50,00
    S[18:34:05][Info][]: Note stacked (stacker)	[18:34:03][Info][]: Credit 100,00
    S[18:34:12][Info][]: Note stacked (stacker)	[18:34:08][Info][]: Credit 100,00
    S[18:34:18][Info][]: Note stacked (stacker)	[18:34:15][Info][]: Credit 50,00
    S[19:44:14][Info][]: Note stacked (stacker)	[19:44:11][Info][]: Credit 100,00
    S[19:44:25][Info][]: Note stacked (stacker)	[19:44:22][Info][]: Credit 50,00
    S[19:44:31][Info][]: Note stacked (stacker)	[19:44:29][Info][]: Credit 1000,00
    

    Finally, with this second regex S/R :

    SEARCH ^(.)(.+)\t(.+)(?=\R\1|\R(.)|\Z)

    REPLACE \3\r\n\2?4\r\n==========================================

    you should get your expected text :

    [15:02:16][Info][]: Credit 500,00
    [15:02:20][Info][]: Note stored (payout)
    [19:44:42][Info][]: Credit 50,00
    [19:44:45][Info][]: Note stored (payout)
    ==========================================
    [14:40:15][Info][]: Credit 100,00
    [14:40:19][Info][]: Note stacked (stacker)
    [14:40:21][Info][]: Credit 100,00
    [14:40:24][Info][]: Note stacked (stacker)
    [14:40:27][Info][]: Credit 100,00
    [14:40:29][Info][]: Note stacked (stacker)
    [16:53:08][Info][]: Credit 200,00
    [16:53:11][Info][]: Note stacked (stacker)
    [16:53:33][Info][]: Credit 100,00
    [16:53:35][Info][]: Note stacked (stacker)
    [17:45:07][Info][]: Credit 200,00
    [17:45:11][Info][]: Note stacked (stacker)
    [17:45:13][Info][]: Credit 200,00
    [17:45:16][Info][]: Note stacked (stacker)
    [17:45:56][Info][]: Credit 50,00
    [17:45:59][Info][]: Note stacked (stacker)
    [18:34:03][Info][]: Credit 100,00
    [18:34:05][Info][]: Note stacked (stacker)
    [18:34:08][Info][]: Credit 100,00
    [18:34:12][Info][]: Note stacked (stacker)
    [18:34:15][Info][]: Credit 50,00
    [18:34:18][Info][]: Note stacked (stacker)
    [19:44:11][Info][]: Credit 100,00
    [19:44:14][Info][]: Note stacked (stacker)
    [19:44:22][Info][]: Credit 50,00
    [19:44:25][Info][]: Note stacked (stacker)
    [19:44:29][Info][]: Credit 1000,00
    [19:44:31][Info][]: Note stacked (stacker)
    

    Et voilà !

    As you can see :

    • The lines have been moved in their original order

    • The payout group comes first, then a =========== delimiter line is written and, afterwards, the stacker group is displayed

    • For each group, the initial sort, by time, is kept

    Best Regards

    guy038



  • @guy038 nice!! thank you!



  • Hello,@Сергей-Бычков
    Please follow this information, To Search multiple strings in all opened files.

    Go to Search > Find in Files (Ctrl+Shift+F for the keyboard addicted) and enter:

    1.Find What = (test1|test2)
    2.Filters = *.txt
    3.Directory = enter the path of the directory you want to search in. You can check to Follow the current doc. to have the path of the current file to be filled.
    4.Search mode = Regular Expression

    I hope this information will be useful to you.
    Thank you.


Log in to reply