Notepad++ 记事本++;如果行包含,如何替换结束

Notepad++ 记事本++;如果行包含,如何替换结束,notepad++,Notepad++,我真的需要你的帮助! 这是我目前的情况: 如果一行包含“菜单::选择” 我需要记事本++来替换结尾“);“为”,true) 看起来是这样的: Menu::choose("Godmode", godmode, true); Menu::choose("No Ragdoll", rag, true); 有办法吗?在“替换”对话框中,您需要输入以下内容: 在“查找内容:”框中,您可以输入: Menu::choose\((.*)\); Menu::c

我真的需要你的帮助! 这是我目前的情况:

如果一行包含“菜单::选择”

我需要记事本++来替换结尾“);“为”,true) 看起来是这样的:

Menu::choose("Godmode", godmode, true);
Menu::choose("No Ragdoll", rag, true);

有办法吗?

在“替换”对话框中,您需要输入以下内容:

  • 在“查找内容:”框中,您可以输入:

      Menu::choose\((.*)\);
    
      Menu::choose\(\1, true\);
    
  • 在“替换为:”框中,您可以输入:

      Menu::choose\((.*)\);
    
      Menu::choose\(\1, true\);
    
  • 然后勾选底部的“正则表达式”位

然后,当您点击“全部替换”时,它将匹配与“Find what:”正则表达式匹配的行,并将其替换为“Replace with:”对象(包括额外的“true”参数)

在正则表达式中:

  • 字符
    是特殊的,因此需要在带有
    \(
    \)的正则表达式中转义

  • 表示一个捕获组,它将把与内部匹配的内容分配给
    \1

  • *
    匹配任意数量的字符

所以
菜单::选择\((.*)将匹配:

  • 菜单::选择(
  • 任意数量的字符(分配给
    \1
菜单::选择\(\1,true\)将找到的内容替换为:

  • 菜单::选择(
  • 分配给
    \1
  • ,正确)
      • Ctrl+H
      • 查找内容:
        菜单::选择\([^)]+\K
      • 替换为:
        ,true
      • 检查匹配案例
      • 检查环绕
      • 检查正则表达式
      • 全部替换
      说明:

      Menu::choose    # literally
      \(              # open parenthese, have to be escaped as it has special meaning in regex
      [^)]+           # negative character class, 1 or more NON close parenthesis
      \K              # forget all we have seen until this position
      
      屏幕截图(之前):

      Menu::choose    # literally
      \(              # open parenthese, have to be escaped as it has special meaning in regex
      [^)]+           # negative character class, 1 or more NON close parenthesis
      \K              # forget all we have seen until this position
      

      屏幕截图(之后):

      Menu::choose    # literally
      \(              # open parenthese, have to be escaped as it has special meaning in regex
      [^)]+           # negative character class, 1 or more NON close parenthesis
      \K              # forget all we have seen until this position