From RAD Studio API Documentation
Jump to: navigation, search


function ReplaceStr(const AText, AFromText, AToText: AnsiString): AnsiString;


extern DELPHI_PACKAGE System::AnsiString __fastcall ReplaceStr(const System::AnsiString AText, const System::AnsiString AFromText, const System::AnsiString AToText)/* overload */;


Type Visibility Source Unit Parent
function public
System.AnsiStrings System.AnsiStrings


Replaces all occurrences of a substring within a string, using case-sensitive search.

Use ReplaceStr to replace all occurrences of the substring AFromText with the string AToText, within the string AText. ReplaceStr returns the string obtained after replacement.

Use System.AnsiStrings.ReplaceText to do a case-insensitive replacement.

Note: Both the parameters and the return values are of type AnsiString. To do the replacement in a UnicodeString context, use the System.StrUtils.ReplaceStr function. Also, to do the replacement in a WideString context, use the WideReplaceStr function.

Note: Recursive replacement of substrings is not supported. This means that if the substitution of AToText results in a new match for AFromText, that match is not replaced.

ReplaceStr is the same function as AnsiReplaceStr.

The StringReplace function is a more general replacement routine, giving case-sensitivity options, as well as the option to decide whether to replace all occurrences or just the first occurrence of the substring in the string.

See Also