module Glob: sig end
Wildcard matching
This module implements shell-like wildcard matching. The wildcards it understands:
- ? matches any one character.
- * matches as many characters as possible, but can match 0.
- [XYZ] matches any of the characters between the brackets.
- [!XYZ] matches any character but ones between the brackets.
- The - indicates a range in the classes, unless it is the first or last. Example:
0-9
is the same as 0123456789
.
- \X matches X, even if it's otherwise a special character.
These are pretty close to what POSIX wants. It doesn't have named character classes ([[:alpha:]]). I'm still trying to decide if they're worth the bother.
For anything more complicated, you'll need full regular expressions. I like PCRE, myself.
type t
The type of compiled patterns.
val compile : ?cs:bool -> string -> t
Compile a pattern for matching.
cs
: True if the pattern is case-senstive, false for a case-insensitive pattern. Defaults to case-sensitive.
val exec : t -> string -> bool
Match a compiled pattern against a string
val quick : ?cs:bool -> string -> string -> bool
quick pattern against
does a one-shot match
cs
: True if the pattern is case-senstive, false for a case-insensitive pattern. Defaults to case-sensitive.
val case_sensitive : t -> bool
Returns the case-sensisitiveness of a pattern.
val escape : string -> string
Returns the string with any special wildcard characters escaped.