1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
// Delphi Berlin 10.1
unit Unitreg;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.RegularExpressions;
type
TForm8 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
OpenDialog1: TOpenDialog;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form8: TForm8;
implementation
{$R *.dfm}
procedure TForm8.Button1Click(Sender: TObject);
var Reg : TRegEx;
l : String;
begin
if opendialog1.Execute then
begin
memo1.Clear;
memo2.Clear;
memo1.Lines.LoadFromFile(Opendialog1.FileName);
Reg:=Tregex.Create('^.*0ABUT990102104024.*$'); // avantage, l'expression peut être une variable saisie dans un TEdit
for l in memo1.Lines do
if Reg.IsMatch(l) then memo2.Lines.Add(l);
end;
end;
end. |