downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/regexp.reference.internal-options.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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.internal-options.php',
   
1 => 'Internal option setting',
  ),
 
'up' =>
  array (
   
0 => 'reference.pcre.pattern.syntax.php',
   
1 => 'Pattern Syntax',
  ),
 
'prev' =>
  array (
   
0 => 'regexp.reference.verticalbar.php',
   
1 => 'Vertical bar',
  ),
 
'next' =>
  array (
   
0 => 'regexp.reference.subpatterns.php',
   
1 => 'Subpatterns',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<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:

      </p><table class="doctable table">
       <caption><b>Internal option letters</b></caption>
      
        <tbody valign="middle" class="tbody">
         <tr valign="middle">
          <td align="left"><i>i</i></td>
          <td align="left">for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_CASELESS</a></td>
         </tr>

         <tr valign="middle">
          <td align="left"><i>m</i></td>
          <td align="left">for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_MULTILINE</a></td>
         </tr>

         <tr valign="middle">
          <td align="left"><i>s</i></td>
          <td align="left">for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_DOTALL</a></td>
         </tr>

         <tr valign="middle">
          <td align="left"><i>x</i></td>
          <td align="left">for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_EXTENDED</a></td>
         </tr>

         <tr valign="middle">
          <td align="left"><i>U</i></td>
          <td align="left">for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_UNGREEDY</a></td>
         </tr>

         <tr valign="middle">
          <td align="left"><i>X</i></td>
          <td align="left">for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_EXTRA</a></td>
         </tr>

         <tr valign="middle">
          <td align="left"><i>J</i></td>
          <td align="left">for <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_INFO_JCHANGED</a></td>
         </tr>

        </tbody>
      
      </table>
<p>
     </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 <i>/ab(?i)c/</i> matches only &quot;abc&quot;
      and &quot;abC&quot;. This behaviour has been changed in PCRE 4.0, which is bundled
      since PHP 4.3.3. Before those versions, <i>/ab(?i)c/</i> would
      perform as <i>/abc/i</i> (e.g. matching &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

        <i>(a(?i)b)c</i>

      matches  abc  and  aBc  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,

        <i>(a(?i)b|c)</i>

      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(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites