简体   繁体   English

Notepad ++:删除包含单词“ Correct”及其上方两行的行

[英]Notepad++: Remove lines containing the word “Correct” and the two lines above it

I have a text-file like this: 我有一个像这样的文本文件:

010 2015.06.29 09:57:57.731 WARN  ALWAYS_SAME_TEXT] No notaris found with the given strings (used postadres): DIFFERENT_TEXTS
010 2015.06.29 09:57:58.220 WARN  ALWAYS_SAME_TEXT] No tussenpersoon found with the given strings: DIFFERENT_TEXTS
010 2015.06.29 09:57:59.288 WARN  ALWAYS_SAME_TEXT] More than one cluster (2) found with the given string: DIFFERENT_TEXTS
010 2015.06.29 09:58:00.192 WARN  ALWAYS_SAME_TEXT] More than one cluster (2) found with the given string: DIFFERENT_TEXTS
010 2015.06.29 09:58:02.766 WARN  ALWAYS_SAME_TEXT] No notaris found with the given strings (used bezoekadres): DIFFERENT_TEXTS
Trying to retrieve notaris with postadres instead of bezoekadres
010 2015.06.29 09:58:02.778 WARN  ALWAYS_SAME_TEXT] Correct notaris is found when using the postadres instead of bezoekadres
010 2015.06.29 09:58:03.647 WARN  ALWAYS_SAME_TEXT] No notaris found with the given strings (used bezoekadres): DIFFERENT_TEXTS
Trying to retrieve notaris with postadres instead of bezoekadres
010 2015.06.29 09:58:03.659 WARN  ALWAYS_SAME_TEXT] Correct notaris is found when using the postadres instead of bezoekadres
010 2015.06.29 09:58:03.991 WARN  ALWAYS_SAME_TEXT] No notaris found with the given strings (used bezoekadres): DIFFERENT_TEXTS
Trying to retrieve notaris with postadres instead of bezoekadres
010 2015.06.29 09:58:04.004 WARN  ALWAYS_SAME_TEXT] No notaris found with the given strings (used postadres): DIFFERENT_TEXTS

What I'd like to achieve is removing all of the following lines (containing the word "Correct"): 我想要实现的是删除以下所有行(包含单词“ Correct”):

Correct notaris is found when using the postadres instead of bezoekadres

Including the two lines above it. 包括上面的两行。 So in the example above, I want to remove the following lines: 因此,在上面的示例中,我想删除以下几行:

010 2015.06.29 09:58:02.766 WARN  ALWAYS_SAME_TEXT] No notaris found with the given strings (used bezoekadres): DIFFERENT_TEXTS
Trying to retrieve notaris with postadres instead of bezoekadres
010 2015.06.29 09:58:02.778 WARN  ALWAYS_SAME_TEXT] Correct notaris is found when using the postadres instead of bezoekadres
010 2015.06.29 09:58:03.647 WARN  ALWAYS_SAME_TEXT] No notaris found with the given strings (used bezoekadres): DIFFERENT_TEXTS
Trying to retrieve notaris with postadres instead of bezoekadres
010 2015.06.29 09:58:03.659 WARN  ALWAYS_SAME_TEXT] Correct notaris is found when using the postadres instead of bezoekadres
  • NOTE: ALWAYS_SAME_TEXT and DIFFERENT_TEXTS are replaced for confidentially. 注意: ALWAYS_SAME_TEXTDIFFERENT_TEXTS被替换为机密。 As stated by the names, the ALWAYS_SAME_TEXT is always the same piece of text, and the DIFFERENT_TEXTS have different texts per log-line. 顾名思义, ALWAYS_SAME_TEXT始终是同一段文本,而DIFFERENT_TEXTS每条日志行具有不同的文本。

I know I can use Ctrl + F -> Mark-tab -> Bookmark line checkbox -> Mark all with the Search-term Correct , but how can I also mark all the two lines above the lines containing the word "Correct" , if this is even possible in Notepad++. 我知道我可以使用Ctrl + F - > Mark-tab - > Bookmark line checkbox - > Mark all与搜索项Correct ,但我怎么也标记所有两线包含字线以上的"Correct" ,如果在Notepad ++中甚至可以做到这一点。 There are too many of them to mark by hand. 它们太多,无法手工标记。


Actually, I'm asking the wrong question, so let me try again: 实际上,我问的是错误的问题,所以让我再试一次:

I have a .txt file with log-lines like in the example above and want to remove all lines containing the word Correct and every two lines above that line. 我有一个带有上面示例中的日志行的.txt文件,并且想要删除所有包含单词Correct行以及该行上方的每两行。 I prefer to do this in Notepad++, but if someone has an easy copy-paste file I can run in Visual Studio to achieve the same goal it's also fine by me. 我更喜欢在Notepad ++中执行此操作,但是如果有人有一个简单的复制粘贴文件,我可以在Visual Studio运行以实现相同的目标,我也很好。

Regex: 正则表达式:

.*[\r\n]+.*[\r\n]+.*\bCorrect\b.*[\r\n]*

Replacement string: 替换字符串:

empty string

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM