Replace 删除仅包含特定单词的行
我有一个大的文本文件(discord的消息日志,准备在ML中使用) 可以有如下内容:Replace 删除仅包含特定单词的行,replace,notepad++,line,Replace,Notepad++,Line,我有一个大的文本文件(discord的消息日志,准备在ML中使用) 可以有如下内容: username1 @username2, whats up username2 username1, im good, and username3 is also doing well (唯一用户名的数量相对较少,因此我可以手动查找并替换它们,而且名称更真实,没有数字) 问题是,我需要删除这些行,其中只有username,没有其他内容。 就在这里 @username2, whats up username1
username1
@username2, whats up
username2
username1, im good, and username3 is also doing well
(唯一用户名的数量相对较少,因此我可以手动查找并替换它们,而且名称更真实,没有数字)
问题是,我需要删除这些行,其中只有username
,没有其他内容。
就在这里
@username2, whats up
username1, im good, and username3 is also doing well
blackground:我使用的库将每一行视为单独的文本,因此如果取消删除,它会生成用户名,而不是消息,因为标题名的数量太多
更好的示例取自实际文件:
adyos
He reacted to invitation
adyos
And by the way, basic nightbot commands are up
adyos
And...
Captain Lea Skywalker
MEE6 is better, adyos If I well understand your needs and if you have a small number of usernames, you can use the following:
- Ctrl+H
- Find what:
^(?:adyos|user2)$\R?
- Replace with:
LEAV EMPTY
- CHECK Match case
- CHECK Wrap around
- CHECK Regular expression
- Replace all
Explanation:
^ # beginning of line
(?: # non capture group
adyos # username 1
| # OR
user2 # username 2
) # end group, you can add all your usernames separated by a pipe |
$ # end of line
\R? # optional linebreak
adyos
他对邀请作出了反应
阿德约斯
顺便说一下,基本的nightbot命令已经启动
阿德约斯
而且。。。
莉亚·天行者船长
MEE6更好,adyos如果我非常了解您的需求,并且您有少量用户名,您可以使用以下选项:
- Ctrl+H
- 查找内容:
^(?:adyos | user2)$\R?
- 替换为:
LEAV EMPTY
- 检查匹配案例
- 检查环绕
- 检查正则表达式
- 全部替换
说明:
屏幕截图(之前):
屏幕截图(之后):
第二个示例的预期输出是什么?如何区分用户名和其他文本?对于Tim Biegeleisen:编辑为现在发布Toto:我将手动查找并回复每个名称,大约有10个maxThank!我设法让一些东西工作起来,但很糟糕,这是如此的好。这对我来说是个过分的回答,非常感谢@不客气,很高兴有帮助。请随意将答案标记为已接受,