in reply to Re: Generate a regex from text
in thread Generate a regex from text

Hi Rolf & porg,

$re = join "|", map quotemeta, @column

Shameless plug - I recently wrote the node Building Regex Alternations Dynamically on exactly this topic (keep in mind it is still a draft). Also, if the number of rows in the DB is large, this may result in a giant regex.

Hope this helps,
-- Hauke D

Replies are listed 'Best First'.
Re^3: Generate a regex from text
by LanX (Saint) on Feb 01, 2017 at 16:18 UTC
    > Also, if the number of rows in the DB is large, this may result in a giant regex.

    Well one hits the limit for the trie optimization, splitting into multiple regexes should be done.

    Since   $x =~ /a|b|c|d/ is like  $x =~ /a|b/ or $x =~ /c|d/

    i.e. it'll scale well.

    But that's lost energy as long as the OP doesn't clarify his energy.

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

Re^3: Generate a regex from text
by porg (Novice) on Feb 01, 2017 at 16:25 UTC
    Thanks alot Hauke! This looks similar to what I'm looking for.
Re^3: Generate a regex from text
by LanX (Saint) on Feb 01, 2017 at 15:55 UTC

      Hi LanX,

      all reports that this technique was already in use before you joined the monastery are alternative facts

      I never claimed I invented the technique :-P Relevant?

      Regards,
      -- Hauke D

        Oh you meant you are shameless?

        ...okay... ;-)

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