package re

  1. Overview
  2. Docs
RE is a regular expression library for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

1.14.0.tar.gz
md5=03f4a83100cb9229a796b85c698076e1
sha512=cd2cc39f951ca6b7be631bbb5531ed13bc040e629842671bf6fef3911b20ef1653fa9a1f0aa23b094d252cffc9a9efe7ffca69e50d362ab935bc0cc447548124

doc/re/Re/Posix/index.html

Module Re.PosixSource

References:

Example of how to use this module (to parse some IRC logs):

  type msg =
    { time : string
    ; author : string
    ; content : string
    }

  let re = Core.compile (Re_posix.re "([^:].*:[^:]*:[^:]{2})<.([^>]+)> (.+)$")

  (* parse a line *)
  let match_line line =
    try
      let substrings = Core.exec re line in
      let groups = Core.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 *)
  ;;
Sourceexception Parse_error
Sourceexception Not_supported

Errors that can be raised during the parsing of the regular expression

Sourcetype opt = [
  1. | `ICase
  2. | `NoSub
  3. | `Newline
]
Sourceval re : ?opts:opt list -> string -> (Re__.Ast.cset, [ `Cased | `Uncased ]) Re__.Ast.gen

Parsing of a Posix extended regular expression

Sourceval re_result : ?opts:opt list -> string -> ((Re__.Ast.cset, [ `Cased | `Uncased ]) Re__.Ast.gen, [ `Not_supported | `Parse_error ]) result
Sourceval compile : (Re__.Ast.cset, [ `Cased | `Uncased ]) Re__.Ast.gen -> Re__.Compile.re

compile r is defined as Core.compile (Core.longest r)

Sourceval compile_pat : ?opts:opt list -> string -> Re__.Compile.re

compile_pat ?opts regex compiles the Posix extended regular expression regexp