(************************************************************ fileregexp.ml Created : Sat Nov 2 20:31:35 2002 Last modified: Sat Dec 21 14:10:16 2002 Compile: ocamlopt.opt str.cmxa fileregexp.ml -o fileregexp # FTP Directory: sources/ocaml # ************************************************************) (** @author Takashi Masuyama *) exception Not_matched let target = "/home/tak/test.d/file.ml.gz" let reg = Str.regexp "^\\(.*\\)\\.[^/]*$" let chop_extension id = if (Str.string_match reg id 0) then Str.matched_group 1 id else raise Not_matched let _ = print_endline (chop_extension target); print_endline (Filename.chop_extension target);