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 48 49 50 51 52
| program Exercice_01;
{$APPTYPE CONSOLE}
uses
SysUtils,
{$IF CompilerVersion >= 22.0}
RegularExpressionsCore;
{$ELSE}
PerlRegex; (* http://www.regular-expressions.info/download/TPerlRegEx.zip *)
{$IFEND}
const
SAMPLE: array[0..7] of string = (
'LFPG;08L;86;13829;148;13829;13829;338;0.1',
'LFPG;08R;86;8858;197;8858;8858;336;0.2',
'LFPG;09L;86;8858;197;8858;8858;378;-0.2',
'LFPG;09R;86;13780;148;13780;13780;370;-0.1',
'LFPG;26L;266;8858;197;8858;8858;316;-0.2',
'LFPG;26R;266;13829;148;13829;13829;318;-0.1',
'LFPG;27L;266;13780;148;13780;13780;387;0.1',
'LFPG;27R;266;8858;197;8858;8858;392;0.2'
);
var
r: TPerlRegex;
s: string;
begin
r := TPerlRegEx.Create;
r.RegEx := '(.+);(.+);(.+);(.+);(.+);(.+);(.+);(.+);(.+)';
for s in SAMPLE do
begin
r.Subject := s;
if r.Match then
begin
WriteLn('Ligne complète : ', r.Groups[0]);
WriteLn('Code ICAO : ', r.Groups[1]);
WriteLn('N° piste : ', r.Groups[2]);
WriteLn('Orient. magn. : ', r.Groups[3]);
WriteLn('Longueur : ', r.Groups[4]);
WriteLn('Largeur : ', r.Groups[5]);
WriteLn('Distance disp. décoll. : ', r.Groups[6]);
WriteLn('Distance disp. atterr. : ', r.Groups[7]);
WriteLn('Alt. seuil : ', r.Groups[8]);
WriteLn('Pente : ', r.Groups[9]);
end;
end;
r.Free;
ReadLn;
end. |
Partager