19 lines
1.0 KiB
Objective-C
19 lines
1.0 KiB
Objective-C
let
|
|
ReplaceFunction = ( P_INPUT as nullable text,
|
|
optional P_IS_WHOLE_WORD as nullable logical,
|
|
optional P_SUBSTITUTION as nullable table) as text =>
|
|
let
|
|
isWhole = if (P_IS_WHOLE_WORD = null) then false else P_IS_WHOLE_WORD,
|
|
SubstitutionTable = if P_SUBSTITUTION = null then fP("RENAMING_RULES", "TABLE") else P_SUBSTITUTION,
|
|
ReplacedText = List.Accumulate(Table.ToRows(SubstitutionTable), P_INPUT, (state, substitution) =>
|
|
if isWhole then
|
|
if (state = substitution{0}) then
|
|
substitution{1}
|
|
else
|
|
state
|
|
else
|
|
Text.Replace(state, substitution{0}, substitution{1}))
|
|
in
|
|
ReplacedText
|
|
in
|
|
ReplaceFunction |