From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id DB955BB81 for ; Wed, 22 Dec 2004 08:36:49 +0100 (CET) Received: from mail3.speakeasy.net (mail3.speakeasy.net [216.254.0.203]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iBM7altJ008255 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 22 Dec 2004 08:36:49 +0100 Received: (qmail 30718 invoked from network); 22 Dec 2004 07:36:46 -0000 Received: from dsl081-060-084.sfo1.dsl.speakeasy.net (HELO trout.darktech.org) (chrisrb@[64.81.60.84]) (envelope-sender ) by mail3.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 22 Dec 2004 07:36:46 -0000 Received: by trout.darktech.org (sSMTP sendmail emulation); Tue, 21 Dec 2004 23:44:55 -0800 From: "Evan Martin" Date: Tue, 21 Dec 2004 23:44:55 -0800 To: skaller Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Str.string_match incorrect Message-ID: <20041222074455.GA81342@trout> References: <1103687369.6979.50.camel@pelican.wigram> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1103687369.6979.50.camel@pelican.wigram> User-Agent: Mutt/1.4.2.1i X-Sent-by-Evan: yep X-Miltered: at concorde with ID 41C9240F.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; martine:01 caml-list:01 wrote:01 bug:01 regexp:01 corresponds:01 debatable:01 regexp:01 bool:01 martine:01 expression:01 expression:01 partial:01 match:02 match:02 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.0 X-Spam-Level: On Wed, Dec 22, 2004 at 02:49:30PM +1100, skaller wrote: > This looks like a fairly fundamental bug in Str module.. > (so probably I'm missing something ..) > > This program: > > let m = Str.regexp "a";; > Str.string_match m "aa" 0;; [evaluates to true] This is consistent with the docs, which say: [string_match r s start] tests whether the characters in s starting at position start match the regular expression r. and in general with how regular expression systems work. string_match corresponds to running your automaton directly and seeing whether you end up in an accept state, while string_partial_match effectively adds an extra ".*" to the beginning. (It's more debatable whether this makes sense.) To force a match across the entire string, use $: # Str.string_match (Str.regexp "a$") "aa" 0;; - : bool = false -- Evan Martin martine@danga.com http://neugierig.org