Home  |  Delphi .net Home  |  System.String  |  Replace Method
  
Replace  
Method  
Replaces all occurences of a string with another string
String Class
System NameSpace
CF1.  Function Replace ( OldValue : Char; NewValue : Char ) : String;
CF2.  Function Replace ( OldValue : String; NewValue : String ) : String;
CF : Methods with this mark are Compact Framework Compatible
Description
Replaces all occurences of a single character, or a sequence of characters : OldValue with a new character or string : NewValue in the current string.
 
It is a case sensitive method.
Notes
Like a lot of string methods, the string object itself is not affected - the modified string is returned for assignment.
Microsoft MSDN Links
System
System.String
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  strA, strB     : String;

begin
  strA := 'First is not worst';

  strB := strA.Replace('rst', 'rm');

  Console.WriteLine('strA = ' + strA);
  Console.WriteLine('Replacing ''rst'' with ''rm''');
  Console.WriteLine('strB = ' + strB);

  Console.ReadLine;
end.
   strA = First is not worst
   Replacing 'rst' with 'rm'
   strB = Firm is not worm
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author