module Re_posix:sig
..end
type msg = {
time:string;
author:string;
content:string;
}
let re = Re.compile (Re_posix.re "([^:].*:[^:]*:[^:]{2})<.([^>]+)> (.+)$")
(* parse a line *)
let match_line line =
try
let substrings = Re.exec re line in
let groups = Re.get_all substrings in
(* groups can be obtained directly by index within [substrings] *)
Some {time=groups.(1); author=groups.(2); content=groups.(3)}
with Not_found ->
None (* regex didn't match *)
exception Parse_error
exception Not_supported
typeopt =
[ `ICase | `Newline | `NoSub ]
val re : ?opts:opt list -> string -> Re.t
val compile : Re.t -> Re.re
val compile_pat : ?opts:opt list -> string -> Re.re
compile r
is defined as Re.compile (Re.longest r)