From: "Christopher A. Watford" <christopher.watford@gmail.com>
To: skaller@users.sourceforge.net
Cc: David Brown <caml-list@davidb.org>,
William Lovas <wlovas@stwing.upenn.edu>,
caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Str.string_match incorrect
Date: Fri, 24 Dec 2004 12:40:39 -0500 [thread overview]
Message-ID: <8008871f04122409405d1b9679@mail.gmail.com> (raw)
In-Reply-To: <1103769192.3443.51.camel@pelican.wigram>
> > > 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' }.
> >
> > This is a strange notion of right and wrong. The function behaves exactly
> > as it is specified in the documentation.
>
> Huh? I'm really confused. Two people think the documentation
> is correct for the behaviour.
>
> I do not -- Saying
>
> string x is matched by regexp r
>
> means to me the same as
>
> x is a member of the regular set of strings r denotes
>
> and with that interpretation there is no possible doubt that
> the documentation is wrong and should say
>
> matches a prefix of the argument string
>
> in order to describe the behaviour.
>
Going by PCRE's documentation the regex /a/ matches: 'a', 'aa',
'baaaaa', 'nota bene', and any other string with 'a' anywhere inside.
>From OCaml's description of string_match:
val string_match: regexp -> string -> int -> bool
[string_match r s start] tests whether the characters in s starting at
position start match the regular expression r. The first character of
a string has position 0, as usual.
This sounds to me like you're doing the PCRE: /a/
if you say:
Str.string_match (Str.regexp "a") "ab" 0 ;;
And in PCRE /a/ matches "ab" or "aa" or "ba".
/^a/ matches "aa", "ab", but not "ba", and /a$/ matches "aa", "ba",
but not "ab". So as far as I can tell, OCaml's string_match is correct
as the manual describes.
--
Christopher A. Watford
christopher.watford@gmail.com
http://dorm.tunkeymicket.com
next prev parent reply other threads:[~2004-12-24 17:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-22 3:49 skaller
2004-12-22 7:44 ` [Caml-list] " Evan Martin
2004-12-22 8:00 ` William Lovas
2004-12-22 8:38 ` Evan Martin
2004-12-22 10:37 ` Gerd Stolpmann
2004-12-22 15:57 ` skaller
2004-12-22 16:58 ` David Brown
2004-12-23 2:33 ` skaller
2004-12-24 17:40 ` Christopher A. Watford [this message]
2004-12-25 0:57 ` skaller
2004-12-25 3:07 ` Christopher A. Watford
2004-12-25 4:24 ` skaller
2004-12-26 1:14 ` William Lovas
2004-12-22 17:26 ` Kurt Welgehausen
2004-12-23 2:09 ` skaller
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=8008871f04122409405d1b9679@mail.gmail.com \
--to=christopher.watford@gmail.com \
--cc=caml-list@davidb.org \
--cc=caml-list@yquem.inria.fr \
--cc=skaller@users.sourceforge.net \
--cc=wlovas@stwing.upenn.edu \
/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