StringReplaceAll replaces all occurrences of OldPattern with NewPattern in S string.

OldPattern can be one or more characters.

NewPattern can be one or more characters, or it can be blank, which effectively removes all occurrences of OldPattern.

StringReplaceAll does not recognise case - A is read as the same as a.

Please also review StringReplaceFirst at StringReplaceFirst.

Declaration: Function StringReplaceAll( const S, OldPattern, NewPattern : string) : string;

Examples follow.

procedure OnMapEvent(var Value:Variant);
var
Str1, Str2, Str3, Str4 : string;
begin
Str1 := 'T''was the night before Xmas, When all through the house.'
 
//Returns 'abc|def|g'
Str2 := StringReplaceAll('abc#def#g','#','|');
LogInfo(Str2);
 
//Returns 'T'was the night before Christmas, When all through the house.'
Str3 := StringReplaceAll(Str1,'xmas','Christmas');
LogInfo(Str3);
 
//Returns 'abcdefg'
Str4 := StringReplaceAll('abc#def#g','#','');
LogInfo(Str4);
 
end;