function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;
TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase);
rfReplaceAll Replace all occurrences. If this flag is not present, only the first occurrence of the target substring is replaced.
rfIgnoreCase Match occurrences of the substring case-insensitively. If this flag is not present, only case-sensitive matches are considered.
var
str:string;
begin
str:='we have we have we have';
str:=StringReplace(str, 'we', 'rr',[rfIgnoreCase]);//将第一个'we'替换为'rr'
str:=StringReplace(str, 'we', 'rr',[rfReplaceAll]);//将所有的'we'替换为'rr'