Releases: ahrefs/ppx_regexp
Releases · ahrefs/ppx_regexp
v0.5.6
0.5.5
0.5.4
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
- this mikmatch extension takes all bound expressions to the left (in order) and passes them to
let re = {%mik|some regex|}
as an alternative tolet%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/%pcre
optimized - Fixed escaping for strings and
'\'
in %mik expressions
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.