在一个正则表达式中使用 Notepad++ 将每个匹配项替换为特定值
Replace each match with certain value using Notepad++ in one regular expression
我在 Adobe LiveCycle Designer FormCalc 中有以下代码:
if (form1.subform[0].complete_flag.rawValue == "1") then
$.presence = "invisible";
endif
我想使用带有正则表达式或类似表达式的 N++ find/replace 来替换上面的代码(转换为 JavaScript):
if (form1.subform[0].complete_flag.rawValue == "1") {
this.presence = "invisible";
}
基本上,在 find/replace 中的一个 运行 中,替换为以下内容:
then ==> {
$. ==> this.
endif ==> }
这可以使用 N++ 或类似工具吗?
塔雷克
正则表达式:
(then)|($)|(endif)
替换:(?1{)(?2this)(?3})
这将适用于 Notepad++。
可以找到完整的解释 here,但如果没有链接,其要点是:
The search looks for either of three alternatives separated by the |
. Each alternative has ist own capture brackets. The replace uses the conditional form ?Ntrue-expression:false-expression where N is decimal digit, the clause checks whether capture expression N matches.
我在 Adobe LiveCycle Designer FormCalc 中有以下代码:
if (form1.subform[0].complete_flag.rawValue == "1") then
$.presence = "invisible";
endif
我想使用带有正则表达式或类似表达式的 N++ find/replace 来替换上面的代码(转换为 JavaScript):
if (form1.subform[0].complete_flag.rawValue == "1") {
this.presence = "invisible";
}
基本上,在 find/replace 中的一个 运行 中,替换为以下内容:
then ==> {
$. ==> this.
endif ==> }
这可以使用 N++ 或类似工具吗?
塔雷克
正则表达式:
(then)|($)|(endif)
替换:(?1{)(?2this)(?3})
这将适用于 Notepad++。
可以找到完整的解释 here,但如果没有链接,其要点是:
The search looks for either of three alternatives separated by the
|
. Each alternative has ist own capture brackets. The replace uses the conditional form ?Ntrue-expression:false-expression where N is decimal digit, the clause checks whether capture expression N matches.