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 BBB43BB81 for ; Wed, 22 Dec 2004 18:26:44 +0100 (CET) Received: from redirect4.airmail.net (redirect4.iadfw.net [209.196.123.153]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iBMHQhJC026689 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 22 Dec 2004 18:26:44 +0100 Received: from host-216-39-197-179.mylinuxisp.com ([216.39.197.179] helo=welgehausen.net) by redirect4.airmail.net with smtp (Exim 4.24) id 1ChAI1-000BfC-Ee for caml-list@yquem.inria.fr; Wed, 22 Dec 2004 11:28:45 -0600 Date: Wed, 22 Dec 2004 11:26:11 -0600 From: Kurt Welgehausen To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Str.string_match incorrect Message-ID: <41C9AE33.mailBIK17BLGN@kwel.net> References: <1103687369.6979.50.camel@pelican.wigram> <20041222074455.GA81342@trout> <20041222080009.GA4501@force.stwing.upenn.edu> <1103731044.6979.109.camel@pelican.wigram> In-Reply-To: <1103731044.6979.109.camel@pelican.wigram> User-Agent: nail 10.4 1/19/03 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41C9AE53.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 wrote:01 python's:01 regexp:01 bool:01 regexp:01 bool:01 kaw:98 expression:01 expression:01 compile:01 compile:01 strings: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 Tue, Dec 21, 2004 at 11:44:55PM -0800, Evan Martin wrote: > > 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. > > Then they're simply wrong. The fundamental operation is > to check if a string is in a regular set of strings. > Plainly 'aa' is not in the set { 'a' }. Str.string_match is almost exactly the same as Python's re.match: # Str.string_match (Str.regexp "a") "ab" 0 ;; - : bool = true >>> re.match(re.compile("a"), "ab") #succeeds <_sre.SRE_Match object at 0x8146f60> # Str.string_match (Str.regexp "a") "bab" 0 ;; - : bool = false >>> re.match(re.compile("a"), "bab") #returns None >>> # Str.string_match (Str.regexp "a") "bab" 1 ;; - : bool = true >>> re.match(re.compile("a"), "bab"[1: ]) <_sre.SRE_Match object at 0x814c748> >>> #Python has no parameter to change the start position Regards