(Delphi DLL) StringBuilder ReplaceWord
Demonstrates the ReplaceWord method.
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, StringBuilder;
...
procedure TForm1.Button1Click(Sender: TObject);
var
sb: HCkStringBuilder;
numReplacements: Integer;
begin
sb := CkStringBuilder_Create();
CkStringBuilder_Append(sb,'forest, lumber, lumberjack, jack, timberland');
// The ReplaceWord method replaces word occurances.
// For example:
numReplacements := CkStringBuilder_ReplaceWord(sb,'lumber','timber');
numReplacements := CkStringBuilder_ReplaceWord(sb,'jack','joe');
// The string content is now:
// forest, timber, lumberjack, joe, timberland
Memo1.Lines.Add(CkStringBuilder__getAsString(sb));
CkStringBuilder_Dispose(sb);
end;
|