ppx_regexp

AuthorPetter A. Urkedal <paurkedal@gmail.com>
LicenseLGPL-3 with OCaml linking exception
Homepagehttps://github.com/paurkedal/ppx_regexp
Issue Trackerhttps://github.com/paurkedal/ppx_regexp/issues
Maintainerpaurkedal@gmail.com
Dependencies
&jbuilder
ocaml-migrate-parsetree
ppx_tools_versioned
re
topkg-jbuilder
Availableocaml-version >= "4.02.3"
PublishedAug 21, 2017
Source [http] https://github.com/paurkedal/ppx_regexp/releases/download/v0.3.1/ppx_regexp-0.3.1.tbz
aa1a1aa9e89ec38f2b0596877c9f2819
StatisticsInstalled 21 times last month.
Edithttps://github.com/ocaml/opam-repository/tree/master/packages/ppx_regexp/ppx_regexp.0.3.1/opam

Matching Regular Expressions with OCaml Patterns

This syntax extension turns

match%pcre x with
| {|re1|} -> e1
...
| {|reN|} -> eN
| _ -> e0

into suitable invocations of the ocaml-re library. The patterns are plain strings of the form accepted by Re_pcre, with the following additions:

  • (?<var>...) defines a group and binds whatever it matches as var. The type of var will be string if the match is guaranteed given that the whole pattern matches, and string option if the variable is bound to or nested below an optionally matched group.
  • ?<var> at the start of a pattern binds group 0 as var : string. This may not be the full string if the pattern is unanchored.

A variable is allowed for the universal case and is bound to the matched string. A regular alias is currently not allowed for patterns, since it is not obvious whether is should bind the full string or group 0.

No package is dependent