Source file utils_regex.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
open Base
type t = Pcre.regexp
let of_string string = Pcre.regexp string
let test regexp string = Pcre.pmatch ~rex:regexp string
let regexp text =
Pcre.extract_opt ~rex:regexp text
|> Array.to_list |> List.tl |> Option.bind ~f:List.hd |> Option.join
module Pcre = Pcre