| 1 |
(** NOTE: Only a subset of the PCRE spec is supported *) |
| 2 |
|
| 3 |
exception Parse_error |
| 4 |
exception Not_supported |
| 5 |
|
| 6 |
type regexp = Core.re |
| 7 |
|
| 8 |
type flag = |
| 9 |
[ `CASELESS |
| 10 |
| `MULTILINE |
| 11 |
| `ANCHORED |
| 12 |
| `DOTALL |
| 13 |
] |
| 14 |
|
| 15 |
type groups = Core.Group.t |
| 16 |
|
| 17 |
(** Result of a {!Pcre.full_split} *) |
| 18 |
type split_result = |
| 19 |
| Text of string (** Text part of splitted string *) |
| 20 |
| Delim of string (** Delimiter part of splitted string *) |
| 21 |
| Group of int * string (** Subgroup of matched delimiter (subgroup_nr, subgroup_str) *) |
| 22 |
| NoGroup (** Unmatched subgroup *) |
| 23 |
|
| 24 |
(** [re ~flags s] creates the regexp [s] using the pcre syntax. *) |
| 25 |
val re : ?flags:flag list -> string -> Core.t |
| 26 |
|
| 27 |
(** [re ~flags s] compiles the regexp [s] using the pcre syntax. *) |
| 28 |
val regexp : ?flags:flag list -> string -> regexp |
| 29 |
|
| 30 |
(** [extract ~rex s] executes [rex] on [s] and returns the matching groups. *) |
| 31 |
val extract : rex:regexp -> string -> string array |
| 32 |
|
| 33 |
(** Equivalent to {!Core.exec}. *) |
| 34 |
val exec : rex:regexp -> ?pos:int -> string -> groups |
| 35 |
|
| 36 |
(** Equivalent to {!Core.Group.get}. *) |
| 37 |
val get_substring : groups -> int -> string |
| 38 |
|
| 39 |
(** Return the names of named groups. *) |
| 40 |
val names : regexp -> string array |
| 41 |
|
| 42 |
(** Return the first matched named group, or raise [Not_found]. *) |
| 43 |
val get_named_substring : regexp -> string -> groups -> string |
| 44 |
|
| 45 |
(** Equivalent to {!Core.Group.offset}. *) |
| 46 |
val get_substring_ofs : groups -> int -> int * int |
| 47 |
|
| 48 |
(** Equivalent to {!Core.execp}. *) |
| 49 |
val pmatch : rex:regexp -> string -> bool |
| 50 |
|
| 51 |
val substitute : rex:Core.re -> subst:(string -> string) -> string -> string |
| 52 |
val full_split : ?max:int -> rex:regexp -> string -> split_result list |
| 53 |
val split : rex:regexp -> string -> string list |
| 54 |
val quote : string -> string |
| 55 |
|
| 56 |
(** {2 Deprecated} *) |
| 57 |
|
| 58 |
type substrings = Group.t |