In OCaml, how can I specify a number of occurrences for a pattern in regex? I went through the Str module and cannot find an equivalent for the {n}
quantifier.
For example, if I want to specify a "Year" pattern, i.e. exactly 4 digits, is there any way other than doing "[0-9][0-9][0-9][0-9]"
?
Thanks.
Extending rgrinberg comment, ocaml-re (https://github.com/ocaml/ocaml-re) supports Perl, PCRE and Emacs mode, which support the {m,n} quantifier.
A link to a test showing that it supports it (using the perl mode): https://github.com/ocaml/ocaml-re/blob/master/lib_test/test_perl.ml#L80 .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With