There is no simple method to make many changes in text array at once. For example: in sample text array:
"abcdef"
you want to replace any “a” into “x” and any “c” into “z”.
You have to use Substitute function twice:
Substitute(
Substitute("abcdef","a","x"),
"c","y"
)
It seems not to dificult, but when you want to make many changes, it can be complicated. And.. when the number of changes is not predefined, it may be hard to write simple code.
But, there is ultra simple solution to replace multiple characters in PowerApps in 1 line code.
Let’s define an array of changes you want to make. For example we want to replace
“a” into “x”
“b” into “y”
“[” into “{“
“]” into “}”
Let’s define aray of changes you want to make:
Set(
replacementsArray,
{
src: "ac[]",
dst: "xy{}"
}
)
and source string:
Set(
string2Replace,
"sample text [ with brackets ]"
)
and the code:
Concat(
Split( string2Replace, "" ),
With({ i: Find( Value, replacementsArray.src ) },
If(
IsBlank( i )
,
Value
,
Mid( replacementsArray.dst, i, 1)
)
)
)
Effect:
source text:
sample text [ with brackets ]
result:
sxmple text { with brxykets }
It works!