* [Caml-list] Str broken @ 2004-09-14 9:26 skaller 2004-09-14 9:35 ` micha-1 2004-09-14 9:42 ` Erik de Castro Lopo 0 siblings, 2 replies; 5+ messages in thread From: skaller @ 2004-09-14 9:26 UTC (permalink / raw) To: caml-list The Str module seems not to work: open Str;; let re = "(a\\|b)*abb" let cre = regexp re let s = "ababababb" ;; string_match cre s 0 ;; returns false. This is the classic test from the Dragon book. Before I post a bug report can someone confirm this result please? I'm using: Objective Caml version 3.09+dev0 (2004-07-13) -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Str broken 2004-09-14 9:26 [Caml-list] Str broken skaller @ 2004-09-14 9:35 ` micha-1 2004-09-14 13:05 ` skaller 2004-09-14 9:42 ` Erik de Castro Lopo 1 sibling, 1 reply; 5+ messages in thread From: micha-1 @ 2004-09-14 9:35 UTC (permalink / raw) To: caml-list On Tuesday 14 September 2004 11:26, skaller wrote: > The Str module seems not to work: > > open Str;; > let re = "(a\\|b)*abb" it works with: let re = "\\(a\\|b\\)*abb" ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Str broken 2004-09-14 9:35 ` micha-1 @ 2004-09-14 13:05 ` skaller 0 siblings, 0 replies; 5+ messages in thread From: skaller @ 2004-09-14 13:05 UTC (permalink / raw) To: micha-1; +Cc: caml-list On Tue, 2004-09-14 at 19:35, micha-1@fantasymail.de wrote: > On Tuesday 14 September 2004 11:26, skaller wrote: > > The Str module seems not to work: > > > > open Str;; > > let re = "(a\\|b)*abb" > > it works with: > > let re = "\\(a\\|b\\)*abb" Ah, you are right that I messed the notation (despite actually checking the manual). Thx! -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Str broken 2004-09-14 9:26 [Caml-list] Str broken skaller 2004-09-14 9:35 ` micha-1 @ 2004-09-14 9:42 ` Erik de Castro Lopo 2004-09-14 10:06 ` Keith Wansbrough 1 sibling, 1 reply; 5+ messages in thread From: Erik de Castro Lopo @ 2004-09-14 9:42 UTC (permalink / raw) To: caml-list On 14 Sep 2004 19:26:59 +1000 skaller <skaller@users.sourceforge.net> wrote: > The Str module seems not to work: > > open Str;; > let re = "(a\\|b)*abb" > let cre = regexp re > let s = "ababababb" > ;; > string_match cre s 0 > ;; > > returns false. This is the classic test from the Dragon book. > Before I post a bug report can someone confirm this result please? > I'm using: Objective Caml version 3.09+dev0 (2004-07-13) I'm using 3.07+2 here. The code you posted produced a warning for me. It seems that for ocaml some extra escaping is required in comparison with other languages. Fixing this code: open Str ;; let re = "\\(a\\|b\\)*abb" ;; let cre = regexp re ;; let s = "ababababb" ;; if string_match cre s 0 then print_endline "true" else print_endline "false" ;; prints "true" for me. Cheers, Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." --Brian Kernighan ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Str broken 2004-09-14 9:42 ` Erik de Castro Lopo @ 2004-09-14 10:06 ` Keith Wansbrough 0 siblings, 0 replies; 5+ messages in thread From: Keith Wansbrough @ 2004-09-14 10:06 UTC (permalink / raw) To: Erik de Castro Lopo; +Cc: caml-list Erik wrote: > On 14 Sep 2004 19:26:59 +1000 > skaller <skaller@users.sourceforge.net> wrote: > > > The Str module seems not to work: [..] > > let re = "(a\\|b)*abb" [..] > I'm using 3.07+2 here. The code you posted produced a warning for > me. It seems that for ocaml some extra escaping is required in > comparison with other languages. The documentation says "The syntax for regular expressions is the same as in Gnu Emacs." (sec 22.1). My emacs documentation (v21.2.1) says about regexps: > The special characters are `$', `^', `.', `*', `+', `?', > `[', `]' and `\'. Any other character appearing in a regular > expression is ordinary, unless a `\' precedes it. This is similar to GNU grep (basic) regular expressions, except for the inclusion of '?', and the exclusion of character classes. It's not clear from the documentation whether the other Emacs constructs not listed in the OCaml manual entry are supported, e.g. \(?: ... \), \`, \B, \<, etc. --KW 8-) ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-09-14 13:05 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-09-14 9:26 [Caml-list] Str broken skaller 2004-09-14 9:35 ` micha-1 2004-09-14 13:05 ` skaller 2004-09-14 9:42 ` Erik de Castro Lopo 2004-09-14 10:06 ` Keith Wansbrough
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox