【问题标题】:How to remove all groups that contain a specific word Notepad++如何删除包含特定单词 Notepad++ 的所有组
【发布时间】:2020-05-11 13:13:06
【问题描述】:

我有一个记事本++ 文件,其中有很多包含条目“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”字样的组的文档。

【问题讨论】:

  • 您要删除包含“spawn : 0”的整个部分吗?
  • edit your question 添加示例文本(不是图像)和预期结果。
  • 我已经编辑了我的问题并添加了示例文本而不是图像,是的@Wander3r

标签: regex replace notepad++ minecraft


【解决方案1】:
  • Ctrl+H
  • 查找内容:^\h+world_C:(?:(?!^\h+world_C).)*spawns: 0\b.*?(?=^\h+world_C|\Z)
  • 替换为:LEAVE EMPTY
  • 检查 匹配大小写
  • 检查 环绕
  • CHECK 正则表达式
  • 检查 . 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

屏幕截图(之前):

屏幕截图(之后):

【讨论】:

猜你喜欢
  • 2018-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-05-18
  • 1970-01-01
  • 2015-07-14
  • 1970-01-01
相关资源
最近更新 更多