RosettaCodeData/Task/Regular-expressions/OCaml/regular-expressions-3.ml
2024-10-16 18:07:41 -07:00

10 lines
292 B
OCaml

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")
;;