Sample code for 30+ languages & platforms
Delphi ActiveX

StringBuilder ReplaceWord

Demonstrates the ReplaceWord method.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

...

procedure TForm1.Button1Click(Sender: TObject);
var
sb: TChilkatStringBuilder;
numReplacements: Integer;

begin
sb := TChilkatStringBuilder.Create(Self);
sb.Append('forest, lumber, lumberjack, jack, timberland');

// The ReplaceWord method replaces word occurances.

// For example:
numReplacements := sb.ReplaceWord('lumber','timber');
numReplacements := sb.ReplaceWord('jack','joe');

// The string content is now:
// forest, timber, lumberjack, joe, timberland
Memo1.Lines.Add(sb.GetAsString());
end;