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 47
| procedure TForm1.Button3Click(Sender: TObject);
const
RE = '<br><br>\d{1,2}\.';
RE2 = '<br><br>\d{1,2}\.(.+?)<FINTAG>';
var
MonObjet : TMonObjet;
Z : TStringList;
s : String;
R : TRegexpr;
begin
Z:=TStringList.Create;
Try
if OpenDialog1.Execute then
begin
Z.LoadFromFile(OpenDialog1.FileName);
s:=FormatClaim(Z.Text);
end;
// Premiere etape, je retransforme les balises en ajoutant une fin
R := TRegExpr.Create;
Try
R.Expression := RE;
if r.Exec (s) then
REPEAT
s:=FastReplace(s, R.match[0], '<FINTAG>'+R.Match[0]);
UNTIL not R.ExecNext;
Finally
R.Free;
End;
// J'extrait les textes comme d'habitude mais cette fois-ci c'est plus simple
R := TRegExpr.Create;
Try
R.Expression := RE2;
if r.Exec (s) then
REPEAT
showmessage(FastReplace(FastReplace(R.match[0], '<FINTAG>', ''), '<br><br>', '');
UNTIL not R.ExecNext;
Finally
R.Free;
End;
Finally
Z.Free;
End;
end; |
Partager