Releases: ahrefs/ppx_regexp
Releases · ahrefs/ppx_regexp
0.5.3
0.5.2
0.5.1
New features
%pcre
extension
-
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
-
Added
%pcre
extension to global let definitions of strings, for use inside of the(?U/N<name>)
patterns -
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.