On Tue, 25 Aug 2020, RW wrote:

On Tue, 25 Aug 2020 10:11:13 -0700 (PDT)
John Hardin wrote:

Does anybody know of a command-line (NOT interactive!) tool that will
generate a minimal "or" RE from a list of terms?

For example, given input like:

        17118720
        17159892
        17179275
        17180740
        17182828

...it would generate:

        (?:171(?:18720|59892|79275|8(?:0740|2828)))


I wonder whether it does anything useful at runtime. I would have
thought the compiler would do that itself from simple alternation.

That would be nice. I'm looking at Regexp::Trie as Giovanni suggested. It's possible that was created before the Perl RE compiler got that smart...


--
 John Hardin KA7OHZ                    http://www.impsec.org/~jhardin/
 [email protected]                         pgpk -a [email protected]
 key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C  AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
  Are you a mildly tech-literate politico horrified by the level of
  ignorance demonstrated by lawmakers gearing up to regulate online
  technology they don't even begin to grasp? Cool. Now you have a
  tiny glimpse into a day in the life of a gun owner.   -- Sean Davis
-----------------------------------------------------------------------
 Today: the 1941st anniversary of the destruction of Pompeii

Reply via email to