如何删除包含特定单词的所有组 Notepad++
How to remove all groups that contain a specific word Notepad++
我有一个 notepad++ 文件,其中有很多包含条目的组 "spawn: 0" 我想查找包含该条目的所有组并完全删除这些组。
下面的示例文本显示了我想保留在我的文档中的内容以及我想从我的文档中删除的内容。
world_C:-117123:26:323196:
stacks: Cave Spider:1;
location: world_C:-117123:26:323196
placedby: 1438b703-b91a-4fee-a853-db0d279c30d9
spawns: 90
我想保留上面这个样子的
但我想删除看起来像下面任何一个的那些。
world_C:-201259:37:274108:
spawns: 0
stacks: Cave Spider:1;
location: world_C:-201259:37:274108
world_C:-201269:36:274092:
stacks: Cave Spider:1;
location: world_C:-201269:36:274092
spawns: 0
world_C:-7230:26:325504:
location: world_C:-7230:26:325504
spawns: 0
stacks: Skeleton:1;
world_C:-288294:32:34488:
location: world_C:-288294:32:34488
spawns: 0
stacks: Zombie:1;
world_C:183436:65:240637:
location: world_C:183436:65:240637
spawns: 0
stacks: Spider:1;
world_C:-277077:33:-151565:
stacks: Cave Spider:1;
location: world_C:-277077:33:-151565
spawns: 0
world_C:-277084:49:-151582:
spawns: 0
stacks: Skeleton:1;
location: world_C:-277084:49:-1515821
结果将是一个文档,其中不包含任何包含单词 "spawns: 0" 的组。
- Ctrl+H
- 查找内容:
^\h+world_C:(?:(?!^\h+world_C).)*spawns: 0\b.*?(?=^\h+world_C|\Z)
- 替换为:
LEAVE EMPTY
- 检查 匹配大小写
- 检查 环绕
- 检查 正则表达式
- 检查
. matches newline
- 全部替换
解释:
^ # beginning of line
\h+ # 1 or more horizontal spaces
world_C: # literally
(?: # non capture group
(?!^\h+world_C) # negative lookahead, make sure we haven't world_C with onlyy spaces before
. # any character
)* # end group, may appear 0 or more times
spawns: 0\b # literally, the word boundary prevents matching 0123
.*? # 0 or more any character, not greedy
(?= # positive lookahead, make sure we have after:
^ # beginning of line
\h+ # 1 or more horizontal spaces
world_C # literally
| # OR
\Z # end of file
) # end of lookahead
屏幕截图(之前):
屏幕截图(之后):
我有一个 notepad++ 文件,其中有很多包含条目的组 "spawn: 0" 我想查找包含该条目的所有组并完全删除这些组。
下面的示例文本显示了我想保留在我的文档中的内容以及我想从我的文档中删除的内容。
world_C:-117123:26:323196:
stacks: Cave Spider:1;
location: world_C:-117123:26:323196
placedby: 1438b703-b91a-4fee-a853-db0d279c30d9
spawns: 90
我想保留上面这个样子的
但我想删除看起来像下面任何一个的那些。
world_C:-201259:37:274108:
spawns: 0
stacks: Cave Spider:1;
location: world_C:-201259:37:274108
world_C:-201269:36:274092:
stacks: Cave Spider:1;
location: world_C:-201269:36:274092
spawns: 0
world_C:-7230:26:325504:
location: world_C:-7230:26:325504
spawns: 0
stacks: Skeleton:1;
world_C:-288294:32:34488:
location: world_C:-288294:32:34488
spawns: 0
stacks: Zombie:1;
world_C:183436:65:240637:
location: world_C:183436:65:240637
spawns: 0
stacks: Spider:1;
world_C:-277077:33:-151565:
stacks: Cave Spider:1;
location: world_C:-277077:33:-151565
spawns: 0
world_C:-277084:49:-151582:
spawns: 0
stacks: Skeleton:1;
location: world_C:-277084:49:-1515821
结果将是一个文档,其中不包含任何包含单词 "spawns: 0" 的组。
- Ctrl+H
- 查找内容:
^\h+world_C:(?:(?!^\h+world_C).)*spawns: 0\b.*?(?=^\h+world_C|\Z)
- 替换为:
LEAVE EMPTY
- 检查 匹配大小写
- 检查 环绕
- 检查 正则表达式
- 检查
. matches newline
- 全部替换
解释:
^ # beginning of line
\h+ # 1 or more horizontal spaces
world_C: # literally
(?: # non capture group
(?!^\h+world_C) # negative lookahead, make sure we haven't world_C with onlyy spaces before
. # any character
)* # end group, may appear 0 or more times
spawns: 0\b # literally, the word boundary prevents matching 0123
.*? # 0 or more any character, not greedy
(?= # positive lookahead, make sure we have after:
^ # beginning of line
\h+ # 1 or more horizontal spaces
world_C # literally
| # OR
\Z # end of file
) # end of lookahead
屏幕截图(之前):
屏幕截图(之后):