Skip to content

Releases: ahrefs/ppx_regexp

v0.5.6

17 Jul 15:01
aad34bb
Compare
Choose a tag to compare

New features

  • %mik and %pcre now anchored at pos 0 by default
  • %miks and %pcres available as unanchored versions

Bug fix

Fixed bug where type conversion wasn't being done when the RE consisted of only one variable capture

0.5.5

16 Jul 15:24
c2e11de
Compare
Choose a tag to compare

New features

  • case insentive match for function | {%mik_i|some regex|} -> ...
  • {|/ "" /|} equivalent to {|/ bos eos /|}

0.5.4

16 Jul 00:25
91b1147
Compare
Choose a tag to compare

New features

  • patterns >>> function_name as res
    • this mikmatch extension takes all bound expressions to the left (in order) and passes them to function_name (semantics might change in the future, might not need to be bound at all)
    • the result from this application is named res
  • let re = {%mik|some regex|} as an alternative to let%mik re = {|some regex|}
  • match str with | {%mik|some regex|} -> ... | ...
    • inside a regular match case, only patterns with %mik inside the string definition are compiled to an RE.
    • raw string matching allowed
  • access to RE bound variables inside respective match guards

Bug fixes and more

  • Generated ccode for match%mik/%pcre, function%mik/%pcreoptimized
  • Fixed escaping for strings and '\' in %mik expressions

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.