in reply to Re: Testing regex equivalence
in thread Testing regex equivalence

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