in reply to Searching for regular expression overlaps

Maybe take a look at chapter 6.5 "Regex String Generation" of Dominus's excellent "Higher-Order Perl" book (free download here). Sez MJD:

Given a regex, how can one generate a list of all the strings matched by the regex? The problem can be rather difficult to solve. But the solution with streams is straightforward and compact.
So there you have it: "rather difficult to solve," "straightforward and compact," what are we waiting for?


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Searching for regular expression overlaps
by LanX (Saint) on Aug 12, 2016 at 20:27 UTC
    Thanks for the link, it's a fascinating read (again).

    some things most be noted

    • MJD is restricting himself to a (very powerful) subset of possible regexes. E.g. he's neither covering look ahead, look behind nor embedded Perl.
    • He doesn't cover the question of how to translate a regex to his stream representation.

    BUT fascinating enough he shows later that he can produce a sorted output: first by length and second lexicographic.

    That means one could probably create a "pragmatic" comparison of two streams, i.e. comparing the leading substrings of all solutions up to a certain length and quickly identifying "incompatible" regexes...

    If there is still an overlap possible after n characters one could reject a regex for being too "similar" (potentially compatible).

    Well theoretically, I won't try to implement this. .. :)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      I tend to agree with you and BrowserUk that what Giardap wants is probably the wrong solution to the wrong problem. And I won't, thank goodness, be implementing it either :)


      Give a man a fish:  <%-{-{-{-<

        > And I won't, thank goodness, be implementing it either :)

        Well MJD might be sufficiently motivated ... ;-)

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

Re^2: Searching for regular expression overlaps
by LanX (Saint) on Aug 12, 2016 at 18:36 UTC
    Does calculating overlaps of two regexes really belong to the same problem class like calculating all matches per regex and checking for overlap?

    I doubt this.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!