Debian Codegraph @

vendor/re/src/glob.mli

raw
1 (*
2 RE - A regular expression library
3
4 Copyright (C) 2001 Jerome Vouillon
5 email: [email protected]
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation, with
10 linking exception; either version 2.1 of the License, or (at
11 your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *)
22
23 (** Shell-style regular expressions *)
24
25 exception Parse_error
26
27 (** Implements the semantics of shells patterns. The returned regular
28 expression is unanchored by default.
29
30 Character '*' matches any sequence of characters and character
31 '?' matches a single character.
32 A sequence '[...]' matches any one of the enclosed characters.
33 A sequence '[^...]' or '[!...]' matches any character *but* the enclosed characters.
34 A backslash escapes the following character. The last character of the string cannot
35 be a backslash.
36
37 [anchored] controls whether the regular expression will only match entire
38 strings. Defaults to false.
39
40 [pathname]: If this flag is set, match a slash in string only with a slash in pattern
41 and not by an asterisk ('*') or a question mark ('?') metacharacter, nor by a bracket
42 expression ('[]') containing a slash. Defaults to true.
43
44 [match_backslashes]: If this flag is set, a forward slash will also match a
45 backslash (useful when globbing Windows paths). Note that a backslash in the
46 pattern will continue to escape the following character. Defaults to
47 [false].
48
49 [period]: If this flag is set, a leading period in string has to be matched exactly by
50 a period in pattern. A period is considered to be leading if it is the first
51 character in string, or if both [pathname] is set and the period immediately follows a
52 slash. Defaults to true.
53
54 If [expand_braces] is true, braced sets will expand into multiple globs,
55 e.g. a\{x,y\}b\{1,2\} matches axb1, axb2, ayb1, ayb2. As specified for bash, brace
56 expansion is purely textual and can be nested. Defaults to false.
57
58 [double_asterisk]: If this flag is set, double asterisks ('**') will match slash
59 characters, even if [pathname] is set. The [period] flag still applies. Default to
60 true. *)
61 val glob
62 : ?anchored:bool
63 -> ?pathname:bool
64 -> ?match_backslashes:bool
65 -> ?period:bool
66 -> ?expand_braces:bool
67 -> ?double_asterisk:bool
68 -> string
69 -> Core.t
70
71 (** Same, but allows to choose whether dots at the beginning of a
72 file name need to be explicitly matched (true) or not (false)
73
74 @deprecated Use [glob ~period]. *)
75 val glob' : ?anchored:bool -> bool -> string -> Core.t
76
77 (** This version of [glob] also recognizes the pattern \{..,..\}
78
79 @deprecated Prefer [glob ~expand_braces:true]. *)
80 val globx : ?anchored:bool -> string -> Core.t
81
82 (** This version of [glob'] also recognizes the pattern \{..,..\}
83
84 @deprecated Prefer [glob ~expand_braces:true ~period]. *)
85 val globx' : ?anchored:bool -> bool -> string -> Core.t