Regex Generator

Description
<b id="docs-internal-guid-1a4bd8cc-7e2a-61c1-d1f6-92d19f759141"></b><b id="docs-internal-guid-1a4bd8cc-7e2c-40ee-52b2-54d47f81d872"></b><p dir="ltr"><span style="color: #000000;background-color: transparent;"><b>Input: </b></span><span style="color: #000000;background-color: transparent;">A file containing strings that are (possibly) the product some regular expression, one per line. </span></p><p dir="ltr"><span style="color: #000000;background-color: transparent;"><b>Output: </b></span><span style="color: #000000;background-color: transparent;">A non-trivial regexes that covers the examples in the file. By trivial regex, we mean either a regex that accepts all strings, or a regex/set of regexes that exactly match the inputs. Note that it will not always be possible to cover all examples, and in general, some provided examples will not be usefully coverable. The goal in such cases should be to generate a non-trivial regex that covers the maximum number examples.</span></p><p dir="ltr"><span style="color: #000000;background-color: transparent;">This is not a perfectly well-defined problem and any solution will necessarily be heuristic. The acceptance criterion is just that the submission performs well enough to return results that look reasonable to a human most of the time.</span></p><p dir="ltr"><span style="color: #000000;background-color: transparent;"><b>Helpful resources: </b></span><a href="http://txt2re.com/index.php3"><span style="color: #1155cc;background-color: transparent;">http://txt2re.com/index.php3</span></a><span style="color: #000000;background-color: transparent;"> and </span><span style="color: #1155cc;background-color: transparent;"><a href="https://github.com/mifmif/Generex">https://github.com/mifmif/Generex</a></span><span style="color: #000000;background-color: transparent;"> </span></p><p dir="ltr"><b>Interesting test cases:</b> <a href="https://mathiasbynens.be/demo/url-regex">https://mathiasbynens.be/demo/url-regex</a></p><b style="color: rgb(0, 0, 0);">Examples:</b><br/><p dir="ltr"><span style="color: #000000;background-color: transparent;">[“working”, “eating”, “sitting”, “flying”]  -&gt;  /.+ing/</span></p><p dir="ltr"><span style="color: rgb(0, 0, 0);background-color: transparent;">[“134”, “18.2”, “0”, “-555”] -&gt; /-?[\d\.]+/</span></p><p dir="ltr"><span style="color: #000000;background-color: transparent;">[“012345”, “deadbeef”, “29e78bbe3a5e496ca3d96a5a8fe50bf0”] -&gt; /[0-9a-f]+/</span></p><p dir="ltr"><span style="color: #000000;background-color: transparent;">[“This is a normal sentence, in English.”, “We’re including punctuation too?”] -&gt; /[\w\p\s]+/</span></p><p dir="ltr"><span style="color: #000000;background-color: transparent;">[“</span><a href="mailto:user@domain.com"><span style="color: #1155cc;background-color: transparent;">user@domain.com</span></a><span style="color: #000000;background-color: transparent;">”, “</span><a href="mailto:foo@bar.com"><span style="color: #1155cc;background-color: transparent;">foo@bar.com</span></a><span style="color: #000000;background-color: transparent;">”, “admin@company.net”] -&gt; /\w+@\w+\.\w+</span></p><p dir="ltr"><span style="color: #000000;background-color: transparent;">[“213-555-1212”, “412-822-4433”, “1-332-122-3333”] -&gt; “\d+(-\d+)*”</span></p><br/><p dir="ltr"><span style="color: #000000;background-color: transparent;"><b>Trivial regexes (not acceptable):</b></span></p><p dir="ltr"><span style="color: #000000;background-color: transparent;">/.*/</span></p><span style="color: #000000;background-color: transparent;">/foo|bar|baz/</span>
Discussion
  • {{comment.username}}
Status
Active
submission(s) pending review
Bounty expires in
Bounty expired
Bounty
0
Tags
(no tags)