Re: [pcre-dev] determine if regular expression onlymatchesf…

Αρχική Σελίδα
Delete this message
Συντάκτης: Philip Hazel
Ημερομηνία:  
Προς: Praet Paul
Υ/ο: pcre-dev@exim.org
Αντικείμενο: Re: [pcre-dev] determine if regular expression onlymatchesfixed-length strings
On Fri, 3 Sep 2010, Praet Paul wrote:

> That is indeed the behavior I am looking for :-)


Well, that's good, but does it really help? Consider:

(1)   tot|toot     "matches fixed length strings"
(2)   to{1,2}t     "does not match fixed length strings"


That would be the result of checking for variable quantifiers, although
both patterns match exactly the same two strings.

I remembered that PCRE has to contain code for this, for checking
lookbehind assertions. It behaves exactly as above:

PCRE version 8.10 2010-06-25

/(?<=tot|toot)abc/

/(?<=to{1,2}t)abc/
Failed: lookbehind assertion is not fixed length at offset 12

It's happy with the first version, but not the second.

Is this really what you want, or are you more interested in detecting
unlimited quantifiers such as + or {3,*} ? Such a check could be added
relatively easily, I think.

Philip

--
Philip Hazel