String Replace in Delphi Tutorial

preview_player
Показать описание
If you try to search String Replace On Delphi, or want to know the syntax of String Replace On Delphi just read the sample Delphi programming code below. i will try to show you how easy to replace string on Delphi. StringReplace Delphi,

The StringReplace() function replaces the first or all occurences of a substring OldPattern in SourceString withNewPattern according to Flags settings.The changed string is returned.The Flags may be none, one, or both of these set values:

unit Unit1;

interface

uses
Strutils, // Unit containing the StringReplace Function
Forms, Dialogs;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
end;

var
Form1: TForm1;

implementation
{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
original,changed : string;

begin
// Try to replace all occurrences of a or HATE to LOVE
original := 'I hate you so much';

changed := StringReplace(original, 'hate ', ' Love ',
[rfReplaceAll, rfIgnoreCase]);
ShowMessage('ORIGINAL = '+original+#13+#10+' CHANGED:'+changed);

end;

end.

That All about Delphi StringReplace Function Tutorial,
Рекомендации по теме
Комментарии
Автор

Thank you, so much! I was in doubt in the command full syntax and you made it clear.

BrazRenato