[Overview][Resource strings][Constants][Types][Procedures and functions][Index] Reference for unit 'StrUtils' (#rtl)

StringReplace

Optimized search-and-replace algorithm

Declaration

Source position: strutils.pp line 274

function StringReplace(

  const S: string;

  const OldPattern: string;

  const NewPattern: string;

  Flags: TReplaceFlags;

  out aCount: Integer;

  Algorithm: TStringReplaceAlgorithm = sraDefault

):string; overload;

function StringReplace(

  const S: string;

  const OldPattern: string;

  const NewPattern: string;

  Flags: TReplaceFlags;

  Algorithm: TStringReplaceAlgorithm = sraDefault

):string; overload;

function StringReplace(

  const S: UnicodeString;

  const OldPattern: UnicodeString;

  const NewPattern: UnicodeString;

  Flags: TReplaceFlags

):UnicodeString; overload;

function StringReplace(

  const S: WideString;

  const OldPattern: WideString;

  const NewPattern: WideString;

  Flags: TReplaceFlags

):WideString; overload;

Description

StringReplace replaces one or all occurrences of OldPattern with NewPattern in the string S. The behaviour is controlled by Flags and the search mechanism may be optimized using Algorithm. A list of possible algorithms is specified in TStringReplaceAlgorithm.

For ansistrings, this is an optimized version of the SysUtils.StringReplace algorithm. For widestrings or unicodestrings, the algorithm parameter is ignored and the default mechanism in sysutils is always used.

Errors

None.

See also

SysUtils.StringReplace

  

Replace occurrences of one substring with another in a string.

TStringReplaceAlgorithm

  

Algorithm to use in StringReplace


Documentation generated on: May 14 2021