equivalent regular expressions (e.g. /.../ and /.{3}/ should end up the same

Evidently, you did not try this out yourself before posting. It took me 10 seconds to see that

% perl -Mre=debug -e '/.../' Freeing REx: `","' Compiling REx `...' size 4 Got 36 bytes for offset annotations. first at 1 1: REG_ANY(2) 2: REG_ANY(3) 3: REG_ANY(4) 4: END(0) minlen 3 Offsets: [4] 1[1] 2[1] 3[1] 4[0] Freeing REx: `"..."'

and

% perl -Mre=debug -e '/.{3}/' Freeing REx: `","' Compiling REx `.{3}' size 4 Got 36 bytes for offset annotations. first at 3 1: CURLY {3,3}(4) 3: REG_ANY(0) 4: END(0) minlen 3 Offsets: [4] 2[3] 0[0] 1[1] 5[0] Freeing REx: `".{3}"'

are quite different beasts. So that's not going to fly. Unfortunately, I don't have any better ideas myself. The only thing I can think of would be to take a look at japhy's Regexp::Parser, which will ease the pain of picking a pattern apart, but to put them back together again with an eye to checking for equivalence will be non-trivial.

• another intruder with the mooring in the heart of the Perl


In reply to Re^2: Testing regex equivalence by grinder
in thread Testing regex equivalence by loris

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.