记事本++:查找特定文本并在父行中替换

时间:2018-06-21 11:39:38

标签: notepad++

我想在记事本++文件的以下行中将enabled =“ true”替换为enabled =“ false”。我的文件中有大量此类行需要替换。 Pl。帮我一样。 (带有notepad ++的reg exp)

<Action sortkey="002" enabled="true" desc="Macro_APP_Open" profile="Safety_Type_1_MacroAPPOpen">
<Action sortkey="003" enabled="true" desc="Change_From_Portal_To_Project_View" profile="Change_From_Portal_To_Project_View">
<Action sortkey="04" enabled="true" desc="Project_Open_from_OpenPath_SafetyCert_ProjectView" profile="Click_FirstSteps_PortalView">
<Action sortkey="005" enabled="true" desc="Project_SaveAs" profile="EnterProjectDetails_ToSave">

1 个答案:

答案 0 :(得分:1)

  • Ctrl + H
  • 查找内容:<Action sortkey="\d+".+?enabled="\Ktrue
  • 替换为:false
  • 检查环绕
  • 检查正则表达式
  • 请勿检查. matches newline
  • 全部替换

说明:

<Action sortkey="   : literally
\d+                 : 1 or more digits
"                   : double quote
.+?                 : 1 or more any character, not greedy
enabled="           : literally
\K                  : forget all we have seen until this position
true                : literally

给定示例的结果

<Action sortkey="002" enabled="false" desc="Macro_APP_Open" profile="Safety_Type_1_MacroAPPOpen">
<Action sortkey="003" enabled="false" desc="Change_From_Portal_To_Project_View" profile="Change_From_Portal_To_Project_View">
<Action sortkey="04" enabled="false" desc="Project_Open_from_OpenPath_SafetyCert_ProjectView" profile="Click_FirstSteps_PortalView">
<Action sortkey="005" enabled="false" desc="Project_SaveAs" profile="EnterProjectDetails_ToSave">