Unit 'sysutils' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

TStringHelper.Replace

Replace occurrences of one string with another.

Declaration

Source position: syshelph.inc line 150

public function TStringHelper.Replace(

  OldChar: char;

  NewChar: char

):string; overload;

function TStringHelper.Replace(

  OldChar: char;

  NewChar: char;

  ReplaceFlags: TReplaceFlags

):string; overload;

function TStringHelper.Replace(

  const OldValue: string;

  const NewValue: string

):string; overload;

function TStringHelper.Replace(

  const OldValue: string;

  const NewValue: string;

  ReplaceFlags: TReplaceFlags

):string; overload;

Description

Replace will replace all occurrences of OldChar with NewChar or OldValue with NewValue. The search is case sensitive.

The behaviour of the Replace call can be controlled with the optional ReplaceFlags parameter:

If rfReplaceAll is in the ReplaceFlags, then all occurrences will be replaced, otherwise only the first occurrence is replaced.

If rfCaseInsensitive is in the ReplaceFlags, then the search for OldChar or OldValue is performed ignoring case.

Not specifying the ReplaceFlags parameter is therefore equivalent to specifying [rfReplaceAll].

See also

StringReplace

  

Replace occurrences of one substring with another in a string.

TReplaceFlags

  

Flags for StringReplace function.


Documentation generated on: Feb 02 2025