【问题标题】:Appending Text on the Line Below a Regular Expression Match在正则表达式匹配下方的行上附加文本
【发布时间】:2013-09-20 02:25:55
【问题描述】:

我正在尝试在包含单词“Letters”的每一行下方添加显示为“[value = xxx]”的文本,并在包含单词“Letters”的行后面附加一个逗号,我认为使用正则表达式Notepad++ 可以工作,但我不太明白。此外,匹配的间隔不是规则的(即,它不像在每 3 行添加“[value = xxx]”那么简单)。

我现在的样子:

Properties = "_2nastlsgb",
     Letters = "#,S"
textline2
textline3
Properties = "_1,N",
     Letters = "A"

我希望最终结果类似于:

Properties = "_2nastlsgb",
     Letters = "#,S",
     [value = xxx]
textline2
textline3
Properties = "_1,N",
     Letters = "A",
     [value = xxx]

我真的很接近以下内容,但最终有点偏离: 查找内容:字母(。*) 替换为:\1,\n\t\t\t\t[Value = ###]

结果:

 Properties = "_2nastlsgb",
         s = "#,S",
                [Value = ###]
    textline2
    textline3
    Properties = "_1,N",
         s = "A",
                [Value = ###]

任何帮助将不胜感激。

【问题讨论】:

    标签: regex notepad++


    【解决方案1】:

    尝试使用:

    ^(.*?)(Letters.*)
    

    并替换为:

    $1$2,\n$1[Value = ###]
    

    此正则表达式将采用 Letters 的缩进并将其应用于 Value

    您的正则表达式的问题在于它正在替换 letter 并且没有将其放回原处,因此是唯一的 s

    【讨论】:

      猜你喜欢
      • 2018-12-30
      • 1970-01-01
      • 2021-02-14
      • 1970-01-01
      • 2016-06-29
      • 2016-04-05
      • 1970-01-01
      • 1970-01-01
      • 2010-10-09
      相关资源
      最近更新 更多