Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 10787

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Perl Differences</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reference.pcre.pattern.modifiers.html">Possible modifiers in regex patterns</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reference.pcre.pattern.posix.html">Differences from POSIX regex</a></div>
 <div class="up"><a href="pcre.pattern.html">PCRE Patterns</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="reference.pcre.pattern.differences" class="article">
 <h1>Perl Differences</h1>

 
 <p class="para">
  The differences described here are with respect to Perl 5.005.
  <ol type="1">
   <li class="listitem">
    <span class="simpara">
     By default, a whitespace character is any character  that
     the C library function isspace() recognizes, though it is
     possible to compile PCRE  with alternative character type
     tables. Normally isspace() matches space, formfeed, newline,
     carriage return, horizontal tab, and vertical tab. Perl 5 no
     longer  includes vertical tab in its set of whitespace characters.
     The \v escape that was in the Perl documentation for
     a long time was never in fact recognized. However, the character
     itself was treated as whitespace at least up to 5.002.
     In 5.004 and 5.005 it does not match \s.
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     PCRE does not allow repeat quantifiers on lookahead
     assertions. Perl permits them, but they do not mean what you
     might think. For example, (?!a){3} does not assert that  the
     next three characters are not &quot;a&quot;. It just asserts that the
     next character is not &quot;a&quot; three times.
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     Capturing subpatterns that occur inside negative
     lookahead assertions are counted, but their entries in the
     offsets vector are never set. Perl sets its numerical
     variables from any such patterns that are matched before the
     assertion fails to match something (thereby succeeding), but
     only  if  the negative lookahead assertion contains just one
     branch.
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     Though binary zero characters are supported in  the  subject  string,
     they are not allowed in a pattern string because it is passed as a
     normal C string, terminated  by zero. The escape sequence &quot;\x00&quot; can
     be used in the pattern to represent a binary zero.
    </span>
    </li>
    <li class="listitem">
    <span class="simpara">
     The following Perl escape sequences  are  not  supported:
     \l,  \u,  \L,  \U. In fact these are implemented by
     Perl&#039;s general string-handling and are not part of its
     pattern matching engine.
    </span>
    </li>
    <li class="listitem">
    <span class="simpara">
     The Perl \G assertion is  not  supported  as  it  is  not
     relevant to single pattern matches.
    </span>
    </li>
    <li class="listitem">
    <span class="simpara">
     Fairly obviously, PCRE does not support the (?{code}) and (??{code})
     construction. However, there is support for recursive  patterns.
    </span>
    </li>
    <li class="listitem">
    <span class="simpara">
     There are at the time of writing some  oddities  in  Perl
     5.005_02  concerned  with  the  settings of captured strings
     when part of a pattern is repeated.  For  example,  matching
     &quot;aba&quot;  against the pattern /^(a(b)?)+$/ sets $2 to the value
     &quot;b&quot;, but matching &quot;aabbaa&quot; against /^(aa(bb)?)+$/ leaves  $2
     unset.    However,    if   the   pattern   is   changed   to
     /^(aa(b(b))?)+$/ then $2 (and $3) get set.
     In Perl 5.004 $2 is set in both cases, and that is also <strong><code>TRUE</code></strong>
     of PCRE. If in the future Perl changes to a consistent state
     that is different, PCRE may change to follow.
    </span>
    </li>
    <li class="listitem">
    <span class="simpara">
     Another as yet unresolved discrepancy  is  that  in  Perl
     5.005_02  the  pattern /^(a)?(?(1)a|b)+$/ matches the string
     &quot;a&quot;, whereas in PCRE it does not.  However, in both Perl and
     PCRE /^(a)?a/ matched against &quot;a&quot; leaves $1 unset.
    </span>
    </li>
    <li class="listitem">
    <p class="para">
     PCRE  provides  some  extensions  to  the  Perl  regular
     expression facilities:
      <ol type="1">
       <li class="listitem">
        <span class="simpara">
         Although lookbehind assertions must match  fixed  length
         strings,  each  alternative branch of a lookbehind assertion
         can match a different length of string. Perl 5.005  requires
         them all to have the same length.
       </span>
      </li>
      <li class="listitem">
       <span class="simpara">
        If <a href="reference.pcre.pattern.modifiers.html" class="link">PCRE_DOLLAR_ENDONLY</a>
        is set and <a href="reference.pcre.pattern.modifiers.html" class="link">PCRE_MULTILINE</a> is
        not set, the $ meta-character matches only at the very end of the
        string.
       </span>
      </li>
      <li class="listitem">
       <span class="simpara">
        If <a href="reference.pcre.pattern.modifiers.html" class="link">PCRE_EXTRA</a> is
        set, a backslash followed by a letter with no special meaning is
        faulted.
       </span>
      </li>
      <li class="listitem">
       <span class="simpara">
        If <a href="reference.pcre.pattern.modifiers.html" class="link">PCRE_UNGREEDY</a> is
        set, the greediness of the repetition  quantifiers  is inverted,
        that is, by default they are not greedy, but if followed by a
        question mark they are.
       </span>
      </li>
     </ol>
    </p>
   </li>
  </ol>
 </p>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reference.pcre.pattern.modifiers.html">Possible modifiers in regex patterns</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reference.pcre.pattern.posix.html">Differences from POSIX regex</a></div>
 <div class="up"><a href="pcre.pattern.html">PCRE Patterns</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>