Re: [pcre-dev] PCRE allows quantified anchored regular expre…

Page principale
Supprimer ce message
Auteur: Philip Hazel
Date:  
À: Mahendra Ladhe
CC: pcre-dev
Sujet: Re: [pcre-dev] PCRE allows quantified anchored regular expressions
On Mon, 20 Jul 2009, Mahendra Ladhe wrote:

>      as seen in the screen output below, PCRE does not reject regular expressions
> which are anchored as well as quantified.
> e.g. (^a){2}
>
> mladhe@linux45:~] pcretest
> PCRE version 7.6 2008-01-28
>
>   re> /(^a){2}/
> data> aa
> No match
> data> a
> No match
> data> a\na
> No match
> data>
>
> The given regular expression is not matching with anything. So why to accept it ?
> It should be rejected by PCRE.


There are plenty of patterns that can never match with anything. It is
very easy to invent others, for example /(?=a)b/. PCRE cannot detect
them all, and it does not try. Perl does not reject this pattern either,
and I suspect that few regex engines would.

Philip

--
Philip Hazel