Objective Caml Programs


  • Regexp/OCaml: A syntax extension for regular expression match

Regexp/OCaml: A syntax extension for regular expression match

Regexp/OCaml provides convenient syntax sugar for regular expression match for strings using PCRE/OCaml library. The features of this macro package are the following:

  • Convenient syntax: similar to standard match-with expression
  • Binding matching substrings to variables: no more $1, $2, …
  • Automagical easy-to-use type-coercion: no flood of int_of_string etc.
  • Support for optional-patterns: gives string option type etc.
  • Default values for optional-patterns
  • Named subpatterns (in Python- or Ruby 1.9-style syntax)

A regular expression which appears in the source file will be evaluated only once; it is pre-compiled before actual execution and then cached. The package contains a small macro, called “once”, makes any value to be evaluated only once.



  • 0.9.0 --> 0.9.3:
    • Supporting Objective Caml 3.07.
    • The pattern “(?:” at the head of the pattern was rejected incorrectly.
  • 0.9.3 --> 0.9.5:
    • Supporting Objective Caml 3.07+19.
    • Build process was broken on 64-bit platforms.
  • 0.9.5 -->
    • Fixed a syntax error (which was torelated until OCaml 3.08.0 / 3.09+dev0).
    • Changed License (“exception for QPL clause 6c” issue.)
  • -->
    • Supporting Objective Caml 3.09+dev6.
  • --> 1.0.pre1:
    • Added named subpatterns in Python style (”(?P<var>regexp)”).
  • 1.0.pre1 --> 1.0.0:
    • Added named subpatterns in Ruby1.9 style (”(?<var>regexp)”).
  • 1.0.0 --> 1.0.1~pre1:
    • (test version) support for OCaml 3.10.0 -- 3.12.0 (new camlp4).