From RAD Studio API Documentation
Jump to: navigation, search


function AnsiReplaceStr(const AText, AFromText, AToText: string): string;


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


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


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

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

Use ReplaceText to do a case-insensitive replacement.

Note: The Ansi prefix in the function name appears for backward compatibility reasons only. However, this function is designed for UnicodeString variables. To work with AnsiString variables, use the System.AnsiStrings.StringReplace function. To work with WideString variables, use the System.WideStrUtils.WideStringReplace 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. In writing your application, we recommend that you use ReplaceStr to avoid any confusion caused by the Ansi prefix.

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 the first occurrence of the substring in the string.

See Also