From a3488cb5544e5e18bbb3a1b24f9e61536fe47d9d Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Sun, 8 Dec 2013 17:07:53 +0100 Subject: [PATCH] Use regexp to check if youtube url. - Add basic build command. --- ocaml/build.sh | 1 + ocaml/main.ml | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100755 ocaml/build.sh diff --git a/ocaml/build.sh b/ocaml/build.sh new file mode 100755 index 0000000..f0d5b41 --- /dev/null +++ b/ocaml/build.sh @@ -0,0 +1 @@ +ocamlfind ocamlc -package netclient str.cma main.ml -o cheesebot diff --git a/ocaml/main.ml b/ocaml/main.ml index 9694831..b8055e8 100644 --- a/ocaml/main.ml +++ b/ocaml/main.ml @@ -1,8 +1,10 @@ +open Http_client +open Str + (* Regexp required here *) let is_youtube_url url = - match url with - | "http://www.youtube.com/" -> true - | _ -> false;; + let regexp = Str.regexp "http://www.youtube.com/.+" in + Str.string_match regexp url 0;; (* Maybe have a list of functions and * iter on all the items in the list *)