3 ms·
Regular Expressions in OCaml
- mercurial 12y agoSome background: there is a regular expression module in the small stdlib OCaml ships with (the String module mentioned in the article). Unfortunately, it is terrible and full of global state. The ocaml-re package is interesting but really low-level. However, it has one interesting feature: it makes it possible to build regular expression in a composable, type-safe way. The humane-re package provides higher-level operations, though last time I checked didn't (yet) support substitution.
- ihnorton 12y agoThe ocaml-re module linked in this article is a neat read. A PCRE parser in ~200 lines: https://github.com/ocaml/ocaml-re/blob/master/lib/re_perl.ml https://github.com/ocaml/ocaml-re/blob/master/lib/re_perl.ml