re_test.ml 470 B

1234567891011121314
  1. let test_re () =
  2. let s = "Dienstag, 14.09.2021 06:05 bis 08:30 Uhr" in
  3. let rx =
  4. Re.Pcre.regexp
  5. "([0-9]{2})\\.([0-9]{2})\\.([0-9]{4})[^0-9]+([0-9]{2}:[0-9]{2})[^0-9]+([0-9]{2}:[0-9]{2})"
  6. in
  7. let m = Re.exec rx s in
  8. assert (6 = Re.Group.nb_groups m);
  9. let g idx = Re.Group.get m idx in
  10. assert ("2021-09-14T06:05" = g 3 ^ "-" ^ g 2 ^ "-" ^ g 1 ^ "T" ^ g 4);
  11. assert ("2021-09-14T08:30" = g 3 ^ "-" ^ g 2 ^ "-" ^ g 1 ^ "T" ^ g 5)
  12. let () = test_re ()