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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|