【发布时间】: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_TEXT和DIFFERENT_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