comp.lang.ada
 help / color / mirror / Atom feed
From: "Marc A. Criley" <mcqada@earthlink.net>
Subject: GNAT.Regexp: Am I missing something?
Date: Fri, 20 Apr 2001 18:04:43 GMT
Date: 2001-04-20T18:04:43+00:00	[thread overview]
Message-ID: <3AE06CE9.E1725E0C@earthlink.net> (raw)

I wanted to use GNAT.Regexp to assist with some filename filtering on
Linux, and seeing the following documentation in the package spec made
me optimistic:

   --  A second kind of regular expressions is provided. This one is
more
   --  like the wild card patterns used in file names by the Unix shell
(or
   --  DOS prompt) command lines. The grammar is the following:

      <grammar provided>

Then the function that compiles the regular expression string says:

   function Compile
     (Pattern        : String;
      Glob           : Boolean := False;
      Case_Sensitive : Boolean := True)
      return           Regexp;
   --  Compiles a regular expression S. If the syntax of the given
   --  expression is invalid (does not match above grammar,
Error_In_Regexp
   --  is raised. If Glob is True, the pattern is considered as a
'globbing
   --  pattern', that is a pattern as given by the second grammar above

So, I anticipated that by doing:

   File_Regexp := Compile("*.log", Glob => True);

I would end up with a regular expression that would match filenames
ending in ".log".  However, that's not what's happening, none of my
".log" files get matched with that expression.

If I use a regular expression that leads with a character, like "l*",
that will match all filenames starting with 'l', but of course that's
not what I want.  The behavior I'm seeing with the "Glob" mode is more
like DOS wildcard file matching rather than Unix.

I know that GNAT.Regexp can work any way its creator want, but the
behavior doesn't jive with my expectations based on its documentation
claiming support for "wild card patterns used in file names by the Unix
shell".

Am I overlooking something?  I don't want "true" regular expressions,
I'm just using this to filter filenames based on a user-supplied
pattern, and their expectation would obviously be to use the
filename-matching kind of pattern.

Thanks for any assistance,

Marc



             reply	other threads:[~2001-04-20 18:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-20 18:04 Marc A. Criley [this message]
2001-04-22 14:48 ` GNAT.Regexp: Am I missing something? Jacob Sparre Andersen
2001-04-23  5:33   ` Simon Wright
2001-04-23 21:42     ` Marius Amado Alves
2001-04-26 19:52       ` Simon Wright
replies disabled

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