【问题标题】:Notepad++: Remove lines containing the word "Correct" and the two lines above itNotepad ++:删除包含“正确”一词的行及其上方的两行
【发布时间】:2023-04-09 03:22:02
【问题描述】:

我有一个这样的文本文件:

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

我想要实现的是删除以下所有行(包含“正确”一词):

Correct notaris is found when using the postadres instead of bezoekadres

包括它上面的两行。所以在上面的例子中,我想删除以下几行:

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
  • 注意:ALWAYS_SAME_TEXTDIFFERENT_TEXTS 被替换为 保密。如名称所述,ALWAYS_SAME_TEXT 是 总是同一段文字,而DIFFERENT_TEXTS 有 每个日志行有不同的文本。

我知道我可以使用 Ctrl + F -> Mark-tab -> Bookmark line checkbox -> Mark all 和 Search-term Correct,但是我怎样才能在包含字"Correct",如果这在记事本++中是可能的。它们太多了,无法手工标记。


其实我问错了,让我再试一次:

我有一个.txt 文件,其中包含上例中的日志行,并且想要删除包含单词Correct 的所有行以及该行上方的每两行。我更喜欢在 Notepad++ 中执行此操作,但如果有人有一个简单的复制粘贴文件,我可以在 Visual Studio 中运行以实现相同的目标,我也可以。

【问题讨论】:

    标签: regex replace notepad++ text-files


    【解决方案1】:

    正则表达式:

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

    替换字符串:

    empty string
    

    【讨论】:

    • 完美,谢谢。我编辑了一些小错误(错别字),但它就像一个魅力。
    • 是的,在java中我们需要使用双反斜杠。
    猜你喜欢
    • 1970-01-01
    • 2018-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-20
    • 1970-01-01
    • 2015-07-26
    • 1970-01-01
    相关资源
    最近更新 更多