⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcre.pattern.syntax.differences.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Differences From Perl</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="reference.pcre.pattern.syntax.html">Describes PCRE regex syntax</a></div> <div class="next" style="text-align: right; float: right;"><a href="regexp.reference.html">Regular Expression Details</a></div> <div class="up"><a href="reference.pcre.pattern.syntax.html">Describes PCRE regex syntax</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="pcre.pattern.syntax.differences" class="section">    <h2 class="title">Differences From Perl</h2>    <p class="para">     The differences described here are with respect to Perl 5.005.    <ol class="orderedlist">     <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 <b><tt>TRUE</tt></b>       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 class="orderedlist">         <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 style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="reference.pcre.pattern.syntax.html">Describes PCRE regex syntax</a></div> <div class="next" style="text-align: right; float: right;"><a href="regexp.reference.html">Regular Expression Details</a></div> <div class="up"><a href="reference.pcre.pattern.syntax.html">Describes PCRE regex syntax</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -