comp.lang.ada
 help / color / mirror / Atom feed
* Regular Expressions
@ 2000-01-16  0:00 Kerry W. Lothrop
  2000-01-17  0:00 ` David C. Hoos, Sr.
  0 siblings, 1 reply; 5+ messages in thread
From: Kerry W. Lothrop @ 2000-01-16  0:00 UTC (permalink / raw)


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





^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: regular expressions
@ 1995-02-08 13:50 Stefan Knappe
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Knappe @ 1995-02-08 13:50 UTC (permalink / raw)



I try to do a pattern matching by using aflex and ayacc. 
if you want these programs i have only the source (6 MBytes). (the binaries are installed
already on the computers before i use this).

Good Bye

Stefan Knappe
mkn@cnve.rz.uni-jena.de



^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <3gucrg$2dn@kaiwan009.kaiwan.com>]

end of thread, other threads:[~2000-01-17  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-16  0:00 Regular Expressions Kerry W. Lothrop
2000-01-17  0:00 ` David C. Hoos, Sr.
  -- strict thread matches above, loose matches on Subject: below --
1995-02-08 13:50 regular expressions Stefan Knappe
     [not found] <3gucrg$2dn@kaiwan009.kaiwan.com>
     [not found] ` <3h1h74$hnh@Starbase.NeoSoft.COM>
1995-02-06  2:39   ` Michael Feldman
1995-02-06 23:20 ` John Woodruff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox