Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 11008

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>Anchors</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="regexp.reference.unicode.html">Unicode character properties</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="regexp.reference.dot.html">Dot</a></div>
 <div class="up"><a href="reference.pcre.pattern.syntax.html">PCRE regex syntax</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="regexp.reference.anchors" class="section">
  <h2 class="title">Anchors</h2>
  <p class="para">
   Outside a character class, in the default matching mode, the
   circumflex character (<em>^</em>) is an assertion which
   is true only if the current matching point is at the start  of
   the  subject string. Inside a character class, circumflex (<em>^</em>)
   has an entirely different meaning (see below).
  </p>
  <p class="para">
   Circumflex (<em>^</em>) need not be the first character
   of the pattern if a number of alternatives are involved, but it
   should be the first thing in each alternative in which it appears
   if the pattern is ever to match that branch. If all possible
   alternatives start with a circumflex (<em>^</em>), that is,
   if the pattern is constrained to match only at the start of the subject,
   it is said to be an &quot;anchored&quot; pattern. (There are also other
   constructs that can cause a pattern to be anchored.)
  </p>
  <p class="para">
   A dollar character (<em>$</em>) is an assertion which is
   <strong><code>TRUE</code></strong> only if the current  matching point is at the end of the subject
   string, or immediately before a newline character that is  the  last
   character in the string (by default). Dollar (<em>$</em>)
   need not be the last character of the pattern if a  number  of
   alternatives are  involved,  but it should be the last item in any branch
   in which it appears. Dollar has no  special  meaning  in  a
   character class.
  </p>
  <p class="para">
   The meaning of dollar can be changed so that it matches only
   at the very end of the string, by setting the
   <a href="reference.pcre.pattern.modifiers.html" class="link">PCRE_DOLLAR_ENDONLY</a>
   option at compile or matching time. This does not affect the \Z assertion.
  </p>
  <p class="para">
   The meanings of the circumflex and dollar characters are
   changed if the
   <a href="reference.pcre.pattern.modifiers.html" class="link">PCRE_MULTILINE</a> option
   is set. When this is the case, they match immediately after and
   immediately before an internal &quot;\n&quot; character, respectively, in addition
   to matching at the start and end of the subject string. For example, the
   pattern /^abc$/ matches the subject string &quot;def\nabc&quot; in multiline mode,
   but not otherwise. Consequently, patterns that are anchored in single
   line mode because all branches start with &quot;^&quot; are not anchored in
   multiline mode. The
   <a href="reference.pcre.pattern.modifiers.html" class="link">PCRE_DOLLAR_ENDONLY</a>
   option is ignored if
   <a href="reference.pcre.pattern.modifiers.html" class="link">PCRE_MULTILINE</a> is
   set.
  </p>
  <p class="para">
   Note that the sequences \A, \Z, and \z can be used to  match
   the  start  and end of the subject in both modes, and if all
   branches of a pattern start with \A is it  always  anchored,
   whether <a href="reference.pcre.pattern.modifiers.html" class="link">PCRE_MULTILINE</a>  
   is set or not.
  </p>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="regexp.reference.unicode.html">Unicode character properties</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="regexp.reference.dot.html">Dot</a></div>
 <div class="up"><a href="reference.pcre.pattern.syntax.html">PCRE regex syntax</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>