(************************************************************ test_regexp.ml Created : Tue Nov 26 23:57:06 2002 Last modified: Wed Nov 27 00:02:12 2002 Compile: ocamlopt.opt str.cmxa test_regexp.ml -o test_regexp # FTP Directory: sources/ocaml # ************************************************************) (** @author Takashi Masuyama *) let anchor_regexp = Str.regexp_case_fold "" let test_data2 = "" let _ = List.iter (fun x -> print_endline (if Str.string_match anchor_regexp x 0 then Str.matched_group 1 x else "Not matched")) [test_data; test_data2]; (* matchしなかった test_data を search_forward, string_match でマッチする *) print_endline (if Str.string_match anchor_regexp test_data (Str.search_forward anchor_regexp test_data 0) then Str.matched_group 1 test_data else "Not matched")