使用reepx替换字符串的一部分,使用notepad ++排除特定字符串

时间:2014-05-20 23:05:25

标签: regex notepad++

在多个文件中替换多个变量名时遇到了一些问题,并且不知道如何解决这个问题

当前格式

//"Pain" should be changed to "Items"
assignValue("X39_MS2_var_Pain_MorphinePainCureValueP", 1.0);
assignValue("X39_MS2_var_Pain_MorphinePainMinForFullCureP", 0.5);
assignValue("X39_MS2_var_Pain_MorphineKillPointP", 1);
//"MedicalActions"  should be changed to "Items"
assignValue("X39_MS2_var_MedicalActions_Morphine_DamageHealing", 0.5);

//"Feature" should remain
assignValue("X39_MS2_var_Feature_EnableMorphine", true);

卡片格式

//"Pain" should be changed to "Items"
assignValue("X39_MS2_var_Items_MorphinePainCureValueP", 1.0);
assignValue("X39_MS2_var_Items_MorphinePainMinForFullCureP", 0.5);
assignValue("X39_MS2_var_Items_MorphineKillPointP", 1);
//"MedicalActions"  should be changed to "Items"
assignValue("X39_MS2_var_Items_Morphine_DamageHealing", 0.5);

//"Feature" should remain
assignValue("X39_MS2_var_Feature_EnableMorphine", true);

到目前为止我得到了什么

//is not working but more or less the latest stage of progress
(X39_MS2_..._)^(?!Feature.*)(?=[a-zA-Z]*)(_.*Morphine.*)

//is working but does not ignores the Feature tag ...
(X39_MS2_..._)([a-zA-Z]*)(_.*Morphine.*)

//Was the base of testing which is working with the above examples but is lacking the brackets around the X39_MS2_ tag + the rest of the string)
^(?!.*Feature.*).*_

如果我缺少这个,请告诉我 将尝试提供你们所需要的一切,因为我现在尝试约1小时来解决这个问题,但没有取得进一步进展:/

亲切地问候 X39

2 个答案:

答案 0 :(得分:1)

在N ++中测试过:

搜索:(?<=_)(?:Pain|MedicalActions)(?=_)

替换:Items

关键是你要找的单词前面有一个loobehind和一个前瞻,每个单词都在寻找_

答案 1 :(得分:0)

如果你想改变疼痛疼痛或医疗行动到物品只需使用正则表达式替换:

Pain|MedicalActions

Items

或者你只想要那些有前缀的人?如果是这样那么就去做

X39_MS2_var_(Pain|MedicalActions)

并替换为:

X39_MS2_var_Items

编辑: 如果你想在那里使用你的正则表达式,那就做一些像:

(X39_MS2_..._)([a-zA-Z]*)(_Morphine.*)

因为这确保吗啡是下一个。只是改变单个部分会更简单......