Updates
This commit is contained in:
19
power-query/fReplace.m
Normal file
19
power-query/fReplace.m
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
||||
Reference in New Issue
Block a user