Created
July 15, 2014 01:05
-
-
Save kjseefried/21aead1d07129bef6f28 to your computer and use it in GitHub Desktop.
Example of using GNAT.regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with GNAT.Regexp; | |
with Ada.Text_IO; | |
procedure logs_to_process is | |
Filename : String := "logs_to_process.txt"; | |
File : Ada.Text_IO.File_Type; | |
Line_Count : Natural := 0; | |
ECD_Pattern : String := "*FILENAME*.ECD*"; | |
ETD_Pattern : String := "*FILENAME*.ETD*"; | |
ECD_Re : constant GNAT.Regexp.Regexp := GNAT.Regexp.Compile (ECD_Pattern, Glob => True); | |
ETD_Re : constant GNAT.Regexp.Regexp := GNAT.Regexp.Compile (ETD_Pattern, Glob => True); | |
begin | |
Ada.Text_IO.Open (File => File, | |
Mode => Ada.Text_IO.In_File, | |
Name => Filename); | |
while not Ada.Text_IO.End_Of_File (File) | |
loop | |
declare | |
Line : String := Ada.Text_IO.Get_Line (File); | |
begin | |
Line_Count := Line_Count + 1; | |
if GNAT.Regexp.Match(Line,ETD_Re) then | |
Ada.Text_IO.Put_Line("MDC REPORT Engine Trend TABLE FOUND!"); | |
end if; | |
if GNAT.Regexp.Match(Line,ECD_Re) then | |
Ada.Text_IO.Put_Line("MDC REPORT Engine Config TABLE FOUND!"); | |
end if; | |
end; | |
end loop; | |
Ada.Text_IO.Close (File); | |
end logs_to_process; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment