<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/reference.pcre.pattern.syntax.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'regexp.reference.alternation.php',
    1 => 'Alternation',
    2 => 'Alternation',
  ),
  'up' => 
  array (
    0 => 'reference.pcre.pattern.syntax.php',
    1 => 'PCRE regex syntax',
  ),
  'prev' => 
  array (
    0 => 'regexp.reference.character-classes.php',
    1 => 'Character classes',
  ),
  'next' => 
  array (
    0 => 'regexp.reference.internal-options.php',
    1 => 'Internal option setting',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pcre/pattern.syntax.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="regexp.reference.alternation" class="section">
  <h2 class="title">Alternation</h2>
  <p class="para">
   Vertical bar characters are used to separate alternative
   patterns. For example, the pattern
   <code class="literal">gilbert|sullivan</code>
   matches either &quot;gilbert&quot; or &quot;sullivan&quot;. Any number of alternatives
   may appear, and an empty alternative is permitted
   (matching the empty string). The matching process tries
   each alternative in turn, from left to right, and the first
   one that succeeds is used. If the alternatives are within a
   subpattern (defined below), &quot;succeeds&quot; means matching the
   rest of the main pattern as well as the alternative in the
   subpattern.
  </p>
  <p class="para">
   It is possible to record which alternative was matched by using 
   <code class="literal">(*MARK:NAME)</code> or <code class="literal">(*:NAME)</code>.
   Any number of such <code class="literal">(*MARK)</code> verbs may appear and their
   names do not have to be unique. When a match succeeds, the name of the
   last-encountered <code class="literal">(*MARK:NAME)</code> will be placed among
   matches as if it were a capture group called <code class="literal">MARK</code> so it
   can be read from the <code class="parameter">matches</code> of
   <span class="function"><a href="function.preg-match.php" class="function">preg_match()</a></span> and will be passed to the
   <code class="parameter">callback</code> of <span class="function"><a href="function.preg-replace-callback.php" class="function">preg_replace_callback()</a></span> etc.
  </p>
 </div><?php manual_footer($setup); ?>