Notepad++ doesn't bookmark all marked lines

匿名 (未验证) 提交于 2019-12-03 09:02:45

问题:

I want to filter everything from a log that belongs to a particular user. With the following pattern I can match everything that I am looking for, but when I ask Notepad++ to bookmark these line so I can copy them something stranges happens.

([^\n]+)userB(.+?)(?=([0-9]{4}-[0-9]{2}-[0-9]{2})) 

In front of line 2 and 8 I see a bookmark icon, but the lines: 3,4,5 and 9,10,11 are missing a icon altough they belong to the highlighted text.

Why does Notepad++ highlight the text, but doesn't place the bookmark correctly? And more important how can I fix this?

Here is the log that I am using:

2015-03-02 11:28:44,993 INFO  application [http-0.0.0.0-8080-17]            userA     99:7 12345 some message 2015-03-02 11:28:45,468 WARN  application [http-0.0.0.0-8080-9]             userB     12:2  some message extra information     at some.classes.and.function(Filename.java:123)     at some.classes.and.function(Filename.java:123) 2015-03-02 11:28:44,993 INFO  application [http-0.0.0.0-8080-17]            userA     99:7 12345 some message 2015-03-02 11:28:44,993 INFO  application [http-0.0.0.0-8080-17]            userA     99:7 12345 some message 2015-03-02 11:28:45,468 WARN  application [http-0.0.0.0-8080-9]             userB     12:2  some message extra information     at some.classes.and.function(Filename.java:123)     at some.classes.and.function(Filename.java:123) 2015-03-02 11:28:44,993 INFO  application [http-0.0.0.0-8080-17]            userA     99:7 12345 some message 

回答1:

The following will extract the information you want without using bookmarks and should work in Notepad++ version 6.9.1 onwards.
It assumes that the lines of extra information don't start with a digit.
It deletes the copied lines from the data file so work on a copy of the data file if you want to preserve it.
It is not very efficient because the switch tab command positions the cursor back at the start of a tab's text.
It duplicates the last match for userB. (A minor irritant!)

Description

1) Define shortcuts for switching to next & previous tabs 2) Open the data file with Notepad++ 3) Open a new tab then go back to the data file tab 4) Define a macro `Cut User data. Paste in next tab`   5) Run the macro `Cut User data. Paste in next tab` on the data file to `end of file`   (It needs to be run once prior to running it in `Run a Macro Multiple Times`   because of a quirk of Notepad++) 

Method

1) Settings Shortcut Mapper Main menu
Switch to previous document = Ctrl+Alt+Left
Switch to next document = Ctrl+Alt+Right
Close

2) Open data file with Notepad++

3) File New Ctrl+Alt+Left

4) Start Recording
Find Find what: .+ userB.+\r\n(\D.+\r\n)*
Search Mode = Regular expression
Find Next Alt+F4
Ctrl+X Ctrl+Alt+Right
Ctrl+End Ctrl+V Ctrl+Alt+Left
Stop recording
Save Current Recorded Macro
Name: Cut User data. Paste in next tab OK

5) Macro Cut User data. Paste in next tab
Run a Macro Multiple Times
Macro to run: Cut User data. Paste in next tab
Run until end of file = Yes
Run then when it has stopped Cancel



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!