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
ocamllex regexp problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-03-19 (16:39)
From: Jake Donham <jake.donham@s...>
Subject: Re: ocamllex regexp problem
On Tue, Mar 18, 2008 at 7:03 PM, Jake Donham <jake.donham@skydeck.com>
wrote:

>   let ends_sq = [^']']* ']'
>   let ends_sq_sq = ends_sq ([^']'] ends_sq)* ']'+
>   let ends_sq_sq_ang = ends_sq_sq ([^'>'] ends_sq_sq)* '>'


My colleague Haoyang Wang points out that my regexp, when viewed
nondeterministically, matches "foo]]]>bar]]>", since ']'+ may match only
"]]", then [^'>'] matches the third "]". Changing it to [^'>'']'] repairs
it. So I guess the answer is that Micmatch on PCRE treats the regexp as
greedy, while ocamllex does not.

Thanks to those who replied,

Jake