RosettaCodeData/Task/Regular-expressions/OCaml/regular-expressions-3.ml

11 lines
292 B
OCaml
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
let matched pat str =
try ignore(Pcre.exec ~pat str); (true)
with Not_found -> (false)
;;
let () =
Printf.printf "matched = %b\n" (matched "string$" "I am a string");
Printf.printf "Substitute: %s\n"
(Pcre.replace ~pat:"original" ~templ:"modified" "I am the original string")
;;