Notepad++ - 如何将行首的数字批量复制到每行的另一部分?

Notepad++ - How to mass copy numbers at the beginning of lines to another part of each line?

所以我正在寻找一种更快的方法来批量重新格式化游戏的一些文件。

我有这样的代码:

84045 = {
    name = Sam
    dynasty = 3
    dna = kfsdiofjsoidfj
    culture = example
    religion = example
    martial = 10
    diplomacy = 10
    stewardship = 10
    intrigue = 10
    learning = 10
    add_trait = trait
    add_trait = trait
    add_trait = trait

    father = 84042
    1395.6.7 = {birth = ""}
    1449.6.7 = {death = ""}
}

我需要的是这部分内容:

    1395.6.7 = {birth = ""}
    1449.6.7 = {death = ""}

所以我有数百个这样的条目。我想要的是像“1395.6.7”这样的数字被批量复制并输入引号,结果如下:

    1395.6.7 = {birth = "1395.6.7"}
    1449.6.7 = {death = "1449.6.7"}

我如何在 Notepad++ 中执行此操作(或其他一些简单的方法)?

How can I do this in Notepad++ (or potentially some other easy way)?

您可以在搜索模式中用"}替换所有((\d+\.\d+\.\d+) = {...th = ")"} 正则表达式.

  • Ctrl+H
  • 查找内容:([\d.]+) = {(?:bir|dea)th = "\K(?="})
  • 替换为:</code></li> <li><strong>检查</strong> <em>环绕</em></li> <li><strong>检查</strong> <em>正则表达式</em></li> <li><kbd>全部替换</kbd></li> </ul> <p><strong>解释:</strong></p> <pre><code>([\d.]+) # group 1, 1 or more digit or dot = { # literally (?:bir|dea) # non capture group, bir OR dea th = " # literally \K # forget all we have seen until this position (?="}) # positive lookahead, make sure we have a quote and closing bracket after

    屏幕截图(之前):

    截图(之后):