<?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 => 'uk',
  ),
  'this' => 
  array (
    0 => 'regexp.reference.internal-options.php',
    1 => 'Internal option setting',
    2 => 'Internal option setting',
  ),
  'up' => 
  array (
    0 => 'reference.pcre.pattern.syntax.php',
    1 => 'PCRE regex syntax',
  ),
  'prev' => 
  array (
    0 => 'regexp.reference.alternation.php',
    1 => 'Alternation',
  ),
  'next' => 
  array (
    0 => 'regexp.reference.subpatterns.php',
    1 => 'Subpatterns',
  ),
  '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.internal-options" class="section">
  <h2 class="title">Internal option setting</h2>
  <p class="para">
   The settings of <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_CASELESS</a>,
   <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_MULTILINE</a>,
   <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_DOTALL</a>,
   <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_UNGREEDY</a>,
   <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_EXTRA</a>,
   <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_EXTENDED</a>
   and PCRE_DUPNAMES can be changed from within the pattern by
   a sequence of Perl option letters enclosed between &quot;(?&quot; and
   &quot;)&quot;. The option letters are:

   <table class="doctable table">
    <caption><strong>Internal option letters</strong></caption>
    
     <tbody class="tbody">
      <tr>
       <td><code class="literal">i</code></td>
       <td>for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_CASELESS</a></td>
      </tr>

      <tr>
       <td><code class="literal">m</code></td>
       <td>for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_MULTILINE</a></td>
      </tr>

      <tr>
       <td><code class="literal">s</code></td>
       <td>for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_DOTALL</a></td>
      </tr>

      <tr>
       <td><code class="literal">x</code></td>
       <td>for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_EXTENDED</a></td>
      </tr>

      <tr>
       <td><code class="literal">U</code></td>
       <td>for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_UNGREEDY</a></td>
      </tr>

      <tr>
       <td><code class="literal">X</code></td>
       <td>for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_EXTRA</a>
        (no longer supported as of PHP 7.3.0)</td>
      </tr>

      <tr>
       <td><code class="literal">J</code></td>
       <td>for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_INFO_JCHANGED</a></td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="para">
   For example, (?im) sets case-insensitive (caseless), multiline matching. It is
   also possible to unset these options by preceding the letter
   with a hyphen, and a combined setting and unsetting such as
   (?im-sx), which sets <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_CASELESS</a> and
   <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_MULTILINE</a>
   while unsetting <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_DOTALL</a> and
   <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_EXTENDED</a>,
   is also permitted. If a letter appears both before and after the
   hyphen, the option is unset.
  </p>
  <p class="para">
   When an option change occurs at top level (that is, not inside
   subpattern parentheses), the change applies to the remainder of the
   pattern that follows. So <code class="literal">/ab(?i)c/</code> matches only &quot;abc&quot;
   and &quot;abC&quot;.
  </p>
  <p class="para">
   If an option change occurs inside a subpattern, the effect
   is different. This is a change of behaviour in Perl 5.005.
   An option change inside a subpattern affects only that part
   of the subpattern that follows it, so

   <code class="literal">(a(?i)b)c</code>

   matches &quot;abc&quot; and &quot;aBc&quot; and no other strings (assuming <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_CASELESS</a> is not
   used). By this means, options can be made to have different settings in
   different parts of the pattern. Any changes made in one alternative do
   carry on into subsequent branches within the same subpattern. For
   example,

   <code class="literal">(a(?i)b|c)</code>

   matches &quot;ab&quot;, &quot;aB&quot;, &quot;c&quot;, and &quot;C&quot;, even though when matching
   &quot;C&quot; the first branch is abandoned before the option setting.
   This is because the effects of option settings happen at
   compile time. There would be some very weird behaviour otherwise.
  </p>
  <p class="para">
   The PCRE-specific options <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_UNGREEDY</a> and
   <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_EXTRA</a> can
   be changed in the same way as the Perl-compatible options by
   using the characters U and X respectively. The (?X) flag
   setting is special in that it must always occur earlier in
   the pattern than any of the additional features it turns on,
   even when it is at top level. It is best put at the start.
  </p>
 </div><?php manual_footer($setup); ?>