From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.1 required=5.0 tests=INFO_TLD, RCVD_IN_BL_SPAMCOP_NET autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 77EB0BC0B for ; Tue, 28 Nov 2006 22:04:56 +0100 (CET) Received: from 42.mail-out.ovh.net (42.mail-out.ovh.net [213.251.189.42]) by discorde.inria.fr (8.13.6/8.13.6) with SMTP id kASL4u2M001001 for ; Tue, 28 Nov 2006 22:04:56 +0100 Received: (qmail 21679 invoked by uid 503); 28 Nov 2006 21:04:56 -0000 Received: from b6.ovh.net (HELO mail240.ha.ovh.net) (213.186.33.56) by 42.mail-out.ovh.net with SMTP; 28 Nov 2006 21:04:56 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 28 Nov 2006 21:01:51 -0000 Received: from vil93-4-82-227-140-227.fbx.proxad.net (HELO ?192.168.1.2?) (lists%philippewang.info@82.227.140.227) by ns0.ovh.net with SMTP; 28 Nov 2006 21:01:50 -0000 Message-ID: <456CA3B7.1020508@philippewang.info> Date: Tue, 28 Nov 2006 22:01:43 +0100 From: Philippe Wang User-Agent: Thunderbird 1.5.0.8 (Macintosh/20061025) MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] About the O'Reilly book on the web References: <45688DAE.7010309@ccr.jussieu.fr> <456AAABE.5020405@irisa.fr> In-Reply-To: <456AAABE.5020405@irisa.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Remote: 82.227.140.227 (vil93-4-82-227-140-227.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Miltered: at discorde with ID 456CA478.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; o'reilly:01 oreilly-book:01 ocaml:01 ocaml:01 o'reilly:01 oreilly-book:01 followin:01 regexp:01 backslash:01 regexp:01 beginner's:01 bug:01 groupings:98 beginners:01 wrote:01 Hello, If you look closer, you can see that the book is about the version 2.04. http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora009.html With OCaml 2.04, you don't have those warnings because they hadn't appeared yet. Objective Caml version 2.04 # "[0-9]+\.[0-9]+\.[0-9]+";; - : string = "[0-9]+\\.[0-9]+\\.[0-9]+" You can probably avoid warnings by backslashing your backslashes... Still I believe the OCaml Team should find another way to express regular expressions, because if \. and \\. both mean \\. then it is a very bad idea... Well, enjoy OCaml :-) -- Philippe Wang mail@philippewang.info PS : I hardly understand what I'm supposed to do to post in this mailing-list, so you have probably not received this one before, but maybe you already have... (I hope this time it'll work...) Sebastien Ferre a écrit : > Hello, > > Francois Colonna wrote: >> Hello >> >> in the version of the O'Reilly book on the web >> http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora105.html#toc134 >> >> Chapter 11 about Str Library page 293 >> >> the followin example of a regular expression is given : >> >> *let*| |english_date_format| ||=|| |Str.regexp| >> ||"[0-9]+\.[0-9]+\.[0-9]+"|| |;; > > There should be a double backslash \\. > Indeed \ is a meta-chararcter of regular expressions, but also > of usual strings. > In general, all backslashes in regular expressions must be > doubled when represented as caml strings. For instance, the > same happens with groupings : > > the regular expression : \([0-9]+\),\1 > > is represented by > > let re = Str.regexp "\\([0-9]+\\),\\1" > > Hope it helps, > Sebastien > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs