如何添加到记事本++中不包括[的行



我正在使用 ^[^[] 来定位所有不以 [.我想将字母 X 添加到所有这些行中,但是使用替换功能它会选择第一个字母,所以如果该行是 hello,我最终会替换它,它会读 Xello。

我可以使用一些参数,这样它就不会选择第一个字母?或者添加而不是替换

Find what"字段中,必须使用(^[^[])
  • 在"Replace"字段中,必须使用X$1
  • 不要忘记检查Search mode中的第一个Regular expression

    • 按 Ctrl+H
    • 查找内容: ^(?![)
    • 替换为:X
    • 选中环绕
    • 检查正则表达式
    • 全部替换

    解释:

    ^       : Beginning of line
    (?!     : start negative lookahead, make sure we don't have the following character
      [    : open bracket
    )       : end lookahead
    

    更换:

    X       : the text you want to add
    

    示例文件:

    abc
    [12]
    a[45]b
    [abcd]
    

    给定示例的结果:

    Xabc
    [12]
    Xa[45]b
    [abcd]
    

    最新更新