Re: Comments on regex-opt

* Joel Yliluoma wrote:
>> A re like foo|[a-z]+ comes out as (?:foo|[a-z]+); this could be further
>> optimized to simply [a-z]+. This is like "Choice counting" which is
>> already listed, but it'd be good to have this example in the docs, I
>> think. The Perl module Regexp::Optimizer reduces (?:aa|a)b to aa?b but
>> does not do this for (?:foo|[a-z]+).
>
>Yes, this is the choice counting problem.
>
>I should think of a way to make the program check if an alternative
>is a subset of another alternative, and thus combine them if they are.

A related case is (xyx(yx)*)|x which becomes x(?:yx(?:yx)*)? but should
become x(?:yx)*.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Thursday, 19 January 2006 09:03:01 UTC