Skip to content

Releases: ahrefs/ppx_regexp

0.5.3

11 Jul 13:40
f6b230c
Compare
Choose a tag to compare

Bug fix

  • := function_name conversion can now be used with module syntax

E.g.

:= Module1.Module2.function_name

0.5.2

11 Jul 13:43
3e0202e
Compare
Choose a tag to compare

New features

  • Guards implemented for %pcre and %mik
  • := function_name conversion

0.5.1

10 Jul 18:07
3b4807d
Compare
Choose a tag to compare

New features

%pcre extension

  1. Added unnamed/named substitution through the use of:

    • (?N<var>), where var is available in the rhs of the match case, and contains the substring matched by the original var
    • (?N<var as name>), where name is available in the rhs of the match case, and contains the substring matched by var
    • (?U<var>), where the substring isn't available in the rhs
  2. Added %pcre extension to global let definitions of strings, for use inside of the (?U/N<name>) patterns

  3. Added new ppx extension for case insensitivity:

    match%pcre_i s with
    | {|regex|} -> ...
    | _ -> ...

    Will case insensitively match {|regex|}.

%mik extension

Mimics the syntax of mikmatch.
Example:

let%mik re_year4 = {|/ digit{4} /|}
let%mik re_month2 = {|/ ('0' ['1'-'9'] | '1' ["012"]) /|}
let%mik re_month = {|/ re_month2 | ['1'-'9'] /|}
let%mik re_day2 = {|/ ('0' ['1'-'9'] | ["12"] digit | '3' ["01"]) /|}
let%mik re_day = {|/ re_day2 | ['1'-'9'] /|}
...
    match%mik s with
    | {|/ (re_year4 as y : int) '-' (re_month as n : int) '-' (re_day as d : int) (any* as rest) eos /|} ->
      Format.printf "y: %d, n: %d, d: %d, rest: %s@." y n d rest
    ...

Errors are well formatted and behave like mikmatch as well.