From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,40f0399c242060cd,start X-Google-Attributes: gid103376,public From: "Kerry W. Lothrop" Subject: Regular Expressions Date: 2000/01/16 Message-ID: <38824937.78FFA393@lothrop.de>#1/1 X-Deja-AN: 573516617 Content-Transfer-Encoding: 7bit Organization: Comp.Center (RUS), U of Stuttgart, FRG X-Accept-Language: de,de-DE, de-AU,de-CH,en,en,en-GB,en-US Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-01-16T00:00:00+00:00 List-Id: Hello, I've just started learning Ada and am having problems extracting information from a text file (in this case it is a flight logger file). I'm used to doing these things in Perl, so I've gotten used to regular expressions, which seem to be available through the package GNAT.Regpat. My first step is to identify the line I'm searching for. It starts with an "H", maybe followed by a space, followed by a letter, maybe followed by a space, followed by "PLT", maybe followed by a space, followed by "PILOT:". I thought this pattern should be "^H ?. ?PLT ?PILOT:". The relevant lines in my program are: while (not End_Of_File(File => File_Name)) loop Get_Line(File => File_Name, Item => Line, Last => Linlen); if Match(Expression => "^H ?. ?PLT ?PILOT:", Data => Line(1 .. Linlen), Size => 10000) then Put_Line(Item => Line(1 .. Linlen)); end if; end loop; The pattern seems to match every line, because the program outputs all the lines in the data file. If I just write the pattern "PILOT" it picks out the right line. If I write the pattern "^H" it outputs all lines. What is it I'm doing wrong? Has anyone worked with GNAT.Regpat? One more thing: Once I have the line, how do I pick out the data after the colon? Thanks, Kerry