Version française
Home     About     Download     Resources     Contact us    
Browse thread
About the O'Reilly book on the web
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Philippe Wang <lists@p...>
Subject: Re: [Caml-list] About the O'Reilly book on the web
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