Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Christophe Raffalli <Christophe.Raffalli@univ-savoie.fr>
To: Tom Ridge <tom.j.ridge+list@googlemail.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Str, regular expressions, longest match
Date: Tue, 30 Sep 2014 14:47:00 +0200	[thread overview]
Message-ID: <20140930124659.GC23852@d45.lama> (raw)
In-Reply-To: <CABooLwNvJ_4frafqjjV0zpoDbduAV5MmVjdrNL=o3ibgMEVoLg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1370 bytes --]

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 = "ab"
>    let reg = "a\\|ab"
>    let _ =A 
>    A  let b = 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 order
>    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

-- 
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 
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2014-09-30 12:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-29 20:04 Tom Ridge
2014-09-30 12:47 ` Christophe Raffalli [this message]
2014-10-01 16:28 ` Xavier Leroy
2014-10-01 19:10   ` Tom Ridge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140930124659.GC23852@d45.lama \
    --to=christophe.raffalli@univ-savoie.fr \
    --cc=caml-list@inria.fr \
    --cc=tom.j.ridge+list@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox