Hacker News new | past | comments | ask | show | jobs | submit login
Regular Expressions in OCaml (rgrinberg.com)
61 points by luu on Nov 16, 2014 | hide | past | favorite | 2 comments



Some 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.


The 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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: