package path_glob
Module Path_glob.GlobSource
A globber is a boolean combination of basic expressions indented to work on pathnames. Known operators are or, and and not, which may also be written |, & and ~. There are also constants true and false (or 1 and 0). Expression can be grouped using parentheses.
truematches anything,falsematches nothing,- basic
orbasic matches strings matching either one of the basic expressions, - basic
andbasic matches strings matching both basic expressions, notbasic matches string that don't match the basic expression,- basic matches strings that match the basic expression.
A basic expression can be a constant string enclosed in double quotes, in which double quotes must be preceded by backslashes, or a glob pattern enclosed between a < and a >,
"string"matches the literal string string,<glob>matches the glob pattern glob.
A glob pattern is an anchored regular expression in a shell-like syntax. Most characters stand for themselves. Character ranges are given in usual shell syntax between brackets. The star * stands for any sequence of characters. The joker '?' stands for exactly one, unspecified character. Alternation is achieved using braces {.
- glob1glob2 matches strings who have a prefix matching glob1 and the corresponding suffix matching glob2.
amatches the string consisting of the single lettera. The alphabet is restricted to[a-z][A-Z][0-9]_-..\\amatches any single lettera.{glob1,glob2}matches strings matching glob1 or glob2.?matches any one-letter string, excluding the slash.*matches all strings not containing a slash, including the empty one.**/matches the empty string, or any string ending with a slash./**matches any string starting with a slash, or the empty string./**/matches any string starting and ending with a slash.[c1-c2c3-c4...]matches characters in the range c1 to c2 inclusive, or in the range c3 to c4 inclusive. For instance[a-fA-F0-9]matches hexadecimal digits. To match the dash, put it at the end.
The type representing fast patterns. Do not attempt to compare them, as they get on-the-fly optimizations.
The type representing globbers. Do not attempt to compare them, as they get on-the-fly optimizations.
parse ~dir pattern will parse the globber pattern pattern, optionally prefixing its patterns with dir.
A descriptive exception raised when an invalid glob pattern description is given.
eval g u returns true if and only if the string u matches the given glob expression. Avoid re-parsing the same pattern, since the automaton implementing the pattern is optimized on the fly. The first few evaluations are done using a time-inefficient but memory-efficient algorithm. It then compiles the pattern into an efficient but more memory-hungry data structure.