I have 2 databases with a column in each where the data is somewhat similar. I want to pull all the data from these columns and generate a regular expression that matches the first DB's data, and a separate regex that matches the second DB's data.

Note- I want to generate this FROM analyzing the text of each DB's data.

(Not relevant): I then want to find the difference between these 2 regexes (so the cases that do not match both -- so an intersection). I would assume i do this via some kind of negation after combining the regexes for both sets of data.

I tried the usual resources (searching monks/google, SO, etc), but I couldn't find anything perl-specific for generating a regex FROM the actual data. Is there some intrinsic logical flaw in trying to generate a regex like this?

Please note, I DO have a bunch of resources I found on PerlMonks that will enable me to develop this myself, I'm mainly curious if this use case's solution is already encompassed in some module.


Thanks!

In reply to Generate a regex from text by porg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.