English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Str.string_match incorrect
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-12-22 (16:58)
From: David Brown <caml-list@d...>
Subject: Re: [Caml-list] Str.string_match incorrect
On Thu, Dec 23, 2004 at 02:57:25AM +1100, skaller wrote:
> On Wed, 2004-12-22 at 19:00, William Lovas wrote:
> > 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' }.

This is a strange notion of right and wrong.  The function behaves exactly
as it is specified in the documentation.  It is not difficult to append a
'$' to the regular expression to only match the entire string.

If the function only matched the entire string, yes, appending ".*" would
cause it to match partial matches, but then it would be more difficult to
extract the matched pattern out.

Arguably, another function could be provided to always do full matching of
strings, but I suspect it just isn't used all that much.