package sihl

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file utils_regex.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
type t = Re.Pcre.regexp

let of_string string = Re.Pcre.regexp string
let test regexp string = Re.Pcre.pmatch ~rex:regexp string

let extract_last regexp text =
  let ( let* ) = Option.bind in
  let extracts = Array.to_list (Re.Pcre.extract ~rex:regexp text) in
  let* extracts =
    try Some (List.tl extracts) with
    | _ -> None
  in
  try Some (List.hd extracts) with
  | _ -> None
;;

module Re = Re
OCaml

Innovation. Community. Security.