How long has it been that regexes have returned anything
predictable from non-matching parenthesis within regexes that match?
With a regex like /A(.)?B/, perl used to fill $1
with whatever the last attempt at a match was, and so the result
was not undefined, but unpredictable. So on a string like 'AB',
you'd end up with 'B' in $1, and although it might be non-intuitive,
it was actually conceptually correct, because the string does
match /A(B)?B/, and it was up to the programmer to
use something more sensible, like </code>/A((.)?)B/</code>, and
only depend on the inner parenthesis if the outer ones contain something besides
the empty string.
But now I guess perl just does (or will do) the right thing :)
-
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.
|