如何多次调用 Filemaker pro 中的 Substitute 函数以在结果中形成一个新列?
How do you invoke the Substitute function in File Maker pro multiple times to form a single new column in your results?
我能够成功地使用 substitute 函数搜索整个字符串列并查找“hello”并将其替换为“world”。
我使用 Calculation field 指令创建了一个运行以下代码的新计算字段:
Substitute(column3;“hello”;“world”)
所以现在我有一个新的 column4,它是 column3 的精确副本,除了“hello”被替换为“world”。
但我还想做更多的替换,例如:
Substitute(column3;“BBB”;“Better Business Bureau”)
Substitute(column3;“CCC”;“Cats Candy Cinder”)
这会创建一条错误消息,指示我需要在替换语句之间放置一个 +、-、* 运算符。我不是真的在这里做数学计算,只是一些字符串操作。
我如何在 File Maker pro 中实现按顺序执行所有 3 个替换的脚本?
你可以这样做:
Substitute(column3;[“AAA”;“Acme”] ; [“BBB”;“Better Business Bureau”] ; [“CCC”;“Cats Candy Cinder”])
这种堆叠替换,使用[],将按顺序替换。它将遍历 column3 三次并分别执行每个替换。所以在第一轮中被替换的东西可能会在下一轮被替换掉。
https://fmhelp.filemaker.com/help/16/fmp/en/index.html#page/FMP_Help/substitute.html
J Brown 的回答是正确的。或者,您可以在单个 Let 函数中进行 3 次替换,如下所示:
Let ( [
_input_text = column3;
_sub1 = Substitute(_input_text; “AAA” ; “Acme” );
_sub2 = Substitute(_sub1; “AAA” ; “Acme” );
_sub3 = Substitute(_sub2; “AAA” ; “Acme” );
_output_text = _sub3
] ;
_output_text
)
我能够成功地使用 substitute 函数搜索整个字符串列并查找“hello”并将其替换为“world”。
我使用 Calculation field 指令创建了一个运行以下代码的新计算字段:
Substitute(column3;“hello”;“world”)
所以现在我有一个新的 column4,它是 column3 的精确副本,除了“hello”被替换为“world”。
但我还想做更多的替换,例如:
Substitute(column3;“BBB”;“Better Business Bureau”)
Substitute(column3;“CCC”;“Cats Candy Cinder”)
这会创建一条错误消息,指示我需要在替换语句之间放置一个 +、-、* 运算符。我不是真的在这里做数学计算,只是一些字符串操作。
我如何在 File Maker pro 中实现按顺序执行所有 3 个替换的脚本?
你可以这样做:
Substitute(column3;[“AAA”;“Acme”] ; [“BBB”;“Better Business Bureau”] ; [“CCC”;“Cats Candy Cinder”])
这种堆叠替换,使用[],将按顺序替换。它将遍历 column3 三次并分别执行每个替换。所以在第一轮中被替换的东西可能会在下一轮被替换掉。
https://fmhelp.filemaker.com/help/16/fmp/en/index.html#page/FMP_Help/substitute.html
J Brown 的回答是正确的。或者,您可以在单个 Let 函数中进行 3 次替换,如下所示:
Let ( [
_input_text = column3;
_sub1 = Substitute(_input_text; “AAA” ; “Acme” );
_sub2 = Substitute(_sub1; “AAA” ; “Acme” );
_sub3 = Substitute(_sub2; “AAA” ; “Acme” );
_output_text = _sub3
] ;
_output_text
)