Module Extended.Re

Additional Re functions.

Typical usage:

module Re = struct include Re include Extended.Re (struct include Re include Re.Glob end) end 

Parameters

module Re : RE

Signature

val findall : ?flags:Re.Pcre.flag list -> ?re:Re.t -> ?pat:string -> string -> string list
val fileglob : ?path:bool -> ?dots:bool -> ?anchored:bool -> string -> string -> bool

(fileglob ?path ?dots ?anchored pat) returns a predicate that matches the pattern pat interpreted as a "classical file glob pattern".

A "classical file glob pattern" supports the shell's *, ?, [], [!], and {} metacharacters; leading dots need to be explicitly matched (unless ~dots:false).

?path determines if slashes need to be matched explicitly (default: true).

?anchored controls whether the regular expression will only match entire strings. (default: true).

Partially apply for efficiency.

N.B. in many cases, you want to use e.g. (Filename.basename >> fileglob "*.c").

Please note these subtle distinctions:

  • File.glob Re.(fileglob "*.ml") "." = [] because glob is matching against names of the form "./prelude.ml".
  • File.glob Re.(Filename.basename >> fileglob "*.ml") "." = ["./prelude.ml"]
  • File.glob Re.(fileglob ~anchored:false "*.ml") "." = ["./prelude.ml~"; "./prelude.ml"; "./prelude.mllib"]