comp.lang.ada
 help / color / mirror / Atom feed
* GNAT.Regexp: Am I missing something?
@ 2001-04-20 18:04 Marc A. Criley
  2001-04-22 14:48 ` Jacob Sparre Andersen
  0 siblings, 1 reply; 5+ messages in thread
From: Marc A. Criley @ 2001-04-20 18:04 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-04-26 19:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-20 18:04 GNAT.Regexp: Am I missing something? Marc A. Criley
2001-04-22 14:48 ` 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

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