From: Tom Ridge <tom.j.ridge+list@googlemail.com>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Str, regular expressions, longest match
Date: Wed, 1 Oct 2014 20:10:55 +0100 [thread overview]
Message-ID: <CABooLwOhbM=CAgTVmHU4qL4p4MWjW2WwoR=YEKhfip2T88SHAQ@mail.gmail.com> (raw)
In-Reply-To: <542C2BA0.8020900@inria.fr>
[-- Attachment #1: Type: text/plain, Size: 1208 bytes --]
Ah great. Thank you.
For reference (for future readers of the caml-list archive perhaps), I can
confirm that ocaml-re supports functionality to specify first or shortest
or longest match.
Tom
On 1 October 2014 17:28, Xavier Leroy <Xavier.Leroy@inria.fr> wrote:
> On 29/09/14 22:04, Tom Ridge wrote:
> > I am trying to use the Str module to match regular expressions. I want to
> > return the longest match.[...] I don't want the order of
> > the alternatives to matter. What am I doing wrong?
>
> Nothing: it's just that Str has first-match semantics, not longest-match.
>
> > What can I do to match the longest substring?
>
> In this particular example, you can sort the string patterns in
> decreasing lexicographic order before putting them in ...|...|...
>
> In more general case, you might have more luck with other regexp
> libraries (e.g. PCRE or Vouillon's RE, but I didn't check whether they
> implement longest match).
>
> Hope this helps,
>
> - Xavier Leroy
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
[-- Attachment #2: Type: text/html, Size: 2003 bytes --]
prev parent reply other threads:[~2014-10-01 19:11 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
2014-10-01 16:28 ` Xavier Leroy
2014-10-01 19:10 ` Tom Ridge [this message]
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='CABooLwOhbM=CAgTVmHU4qL4p4MWjW2WwoR=YEKhfip2T88SHAQ@mail.gmail.com' \
--to=tom.j.ridge+list@googlemail.com \
--cc=Xavier.Leroy@inria.fr \
--cc=caml-list@inria.fr \
/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;
as well as URLs for NNTP newsgroup(s).