Package: GNAT.Regexp

Dependencies

with Ada.Finalization;

Description

GNAT.Spitbol.Patterns (files g-spipat.ads/g-spipat.adb) This is a completely general patterm matching package based on the pattern language of SNOBOL4, as implemented in SPITBOL. The pattern language is modeled on context free grammars, with context sensitive extensions that provide full (type 0) computational capabilities. The regular expression must first be compiled, using the Compile function, which creates a finite state matching table, allowing very fast matching once the expression has been compiled.

Header

package GNAT.Regexp is
 

Exceptions

Error_In_Regexp
Exception raised when an error is found in the regular expression

Type Summary

Regexp
Primitive Operations:  Compile, Match

Other Items:

type Regexp is private;
Important note : This package was mainly intended to match regular expressions against file names. The whole string has to match the regular expression. If only a substring matches, then the function Match will return False. Private type used to represent a regular expression

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

function Match (S : String; R : Regexp) return Boolean;
True if S matches R, otherwise False. Raises Constraint_Error if R is an uninitialized regular expression value.

private

   --  Implementation-defined ...
end GNAT.Regexp;