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

11 lines
292 B
Text
Raw Permalink Normal View History

2013-04-10 23:57:08 -07: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")
;;