Provided by standard library.
REPLACE replaces a partial string from a larger string with a third string.
The input variable STR1 and STR2 are type STRING, LEN and POS are type INT, the return value of the function is type STRING.
REPLACE(STR1, STR2, L, P) means: Replace L characters from STR1 with STR2 beginning with the character in the P position.
Example in Function Block Diagram

Example in Structured Text
VarSTRING1 := REPLACE ('SUXYSI','K',2,2);
String functions are not "thread safe": When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.