From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 060317F02D for ; Tue, 30 Sep 2014 14:47:09 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of Christophe.Raffalli@univ-savoie.fr) identity=pra; client-ip=193.48.126.73; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="raffalli@univ-savoie.fr"; x-sender="Christophe.Raffalli@univ-savoie.fr"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of raffalli@univ-savoie.fr designates 193.48.126.73 as permitted sender) identity=mailfrom; client-ip=193.48.126.73; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="raffalli@univ-savoie.fr"; x-sender="raffalli@univ-savoie.fr"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@dsi-mta-out.univ-savoie.fr) identity=helo; client-ip=193.48.126.73; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="raffalli@univ-savoie.fr"; x-sender="postmaster@dsi-mta-out.univ-savoie.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuYBABCmKlTBMH5JnGdsb2JhbABgFoNLV8oniF8WAREBAQEBAQgLCQkULIQEAQEESQomEAsYCSUPBUkTiEIJvzoYj00BAYQEgR0FhiqSOoRKmVZqAYEOgTsBAQE X-IPAS-Result: AuYBABCmKlTBMH5JnGdsb2JhbABgFoNLV8oniF8WAREBAQEBAQgLCQkULIQEAQEESQomEAsYCSUPBUkTiEIJvzoYj00BAYQEgR0FhiqSOoRKmVZqAYEOgTsBAQE X-IronPort-AV: E=Sophos;i="5.04,626,1406584800"; d="asc'?scan'208";a="81396882" Received: from dsi-mta-out.univ-savoie.fr ([193.48.126.73]) by mail3-smtp-sop.national.inria.fr with ESMTP; 30 Sep 2014 14:47:00 +0200 Received: from localhost (localhost [127.0.0.1]) by dsi-mta-out.univ-savoie.fr (Postfix) with ESMTP id 5F786423A2; Tue, 30 Sep 2014 14:47:00 +0200 (CEST) Received: from dsi-mta-out.univ-savoie.fr ([127.0.0.1]) by localhost (dsi-mta-out.univ-savoie.fr [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id dQPZZQl8DtQK; Tue, 30 Sep 2014 14:47:00 +0200 (CEST) Received: from dsi-mail-msa1.univ-savoie.fr (dsi-mail-msa1.univ-savoie.fr [193.48.126.83]) by dsi-mta-out.univ-savoie.fr (Postfix) with ESMTP id 4CFB4423A1; Tue, 30 Sep 2014 14:47:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by dsi-mail-msa1.univ-savoie.fr (Postfix) with ESMTP id 502B51409C; Tue, 30 Sep 2014 14:47:00 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at dsi-mail-msa1.univ-savoie.fr Received: from dsi-mail-msa1.univ-savoie.fr ([127.0.0.1]) by localhost (dsi-mail-msa1.univ-savoie.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BEtnwfXGV3gg; Tue, 30 Sep 2014 14:47:00 +0200 (CEST) Received: from localhost (d45.lama.univ-savoie.fr [193.48.123.45]) by dsi-mail-msa1.univ-savoie.fr (Postfix) with ESMTPSA id 33BD314099; Tue, 30 Sep 2014 14:47:00 +0200 (CEST) Date: Tue, 30 Sep 2014 14:47:00 +0200 From: Christophe Raffalli To: Tom Ridge Cc: caml-list Message-ID: <20140930124659.GC23852@d45.lama> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TYecfFk8j8mZq+dy" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Validation-by: christophe.raffalli@univ-savoie.fr Subject: Re: [Caml-list] Str, regular expressions, longest match --TYecfFk8j8mZq+dy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 14-09-29 21:04:17, Tom Ridge wrote: > Dear All, > I am trying to use the Str module to match regular expressions. I want= to > return the longest match. > let txt =3D "ab" > let reg =3D "a\\|ab" > let _ =3DA=20 > A let b =3D Str.string_match (Str.regexp reg) txt 0 in > A Str.matched_string txt > After the last line, the string "a" is apparently matched. But I hope = that > the result should be "ab". If I reverse the order of the alternatives = in > the regular expression, the string "ab" is matched. I don't want the o= rder > of the alternatives to matter. What am I doing wrong? What can I do to > match the longest substring? > Thanks > Tom Hello, I had the same problem just last week and almost wrote the same mail. This is at least a bug in the documentation ? Cheers, Christophe --=20 Christophe Raffalli Universite de Savoie Batiment Le Chablais, bureau 21 73376 Le Bourget-du-Lac Cedex tel: (33) 4 79 75 81 03 fax: (33) 4 79 75 87 42 mail: Christophe.Raffalli@univ-savoie.fr www: http://www.lama.univ-savoie.fr/~RAFFALLI --------------------------------------------- IMPORTANT: this mail is signed using PGP/MIME At least Enigmail/Mozilla, mutt or evolution=20 can check this signature. The public key is stored on www.keyserver.net --------------------------------------------- --TYecfFk8j8mZq+dy Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iEYEARECAAYFAlQqpkMACgkQi9jr/RgYAS6/fACgnod4h0e3Uiq7DOJr8TiJncIa PSwAoLx8v1rhlZw6YOqs/gRCQk016YwC =PAFK -----END PGP SIGNATURE----- --TYecfFk8j8mZq+dy--