Re: [pcre-dev] Comparing Regular Expressions

Top Page
Delete this message
Author: Philip Hazel
Date:  
To: John P. Baker
CC: PCRE-Dev
Subject: Re: [pcre-dev] Comparing Regular Expressions
On Wed, 30 Jun 2010, John P. Baker wrote:

> I am new to PCRE, and I am looking at incorporating regular expressions into
> a new product.
>
> I need to know whether either of the following capabilities are available,
> either in PCRE, or in an add-on package -
>
> .         Given two (2) regular expressions, does one regular expression
> superset all possible pattern matches of the other regular expression?


I suspect that is very hard to determine. On my list of way-out possible
things to do when I get bored (i.e. it isn't likely to happen soon) is
to try to write code to generate matching strings from a compiled
pattern. If this could be done, then one could compare the sets of
strings, I suppose.

> .         Given two (2) regular expressions, does there exist any union of
> potential pattern matches?


Do you mean anything more complicated than A|B (where A and B are two
regular expressions)? [In PCRE - and Perl - there are features that
allow you to compose two patterns like that and still allow
backreferences within them to work correctly, i.e. features to fiddle
with the capturing parenthesis numbers.]

Philip

--
Philip Hazel