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/reference.pcre.pattern.modifiers.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/pcre.pattern.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'reference.pcre.pattern.modifiers.php',
   
1 => 'Possible modifiers in regex patterns',
  ),
 
'up' =>
  array (
   
0 => 'pcre.pattern.php',
   
1 => 'PCRE Patterns',
  ),
 
'prev' =>
  array (
   
0 => 'pcre.pattern.php',
   
1 => 'PCRE Patterns',
  ),
 
'next' =>
  array (
   
0 => 'reference.pcre.pattern.differences.php',
   
1 => 'Differences From Perl',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div>
 <h1>Pattern Modifiers</h1>

 
  <p class="para">
   The current possible PCRE modifiers are listed below.  The names
   in parentheses refer to internal PCRE names for these modifiers.
   Spaces and newlines are ignored in modifiers, other characters cause error.
  </p>
  <p class="para">
   <blockquote class="blockquote">
    </p><dl>

     <dt class="varlistentry">

      <span class="term"><em class="emphasis">i</em> (<i>PCRE_CASELESS</i>)</span>

      </dt><dd class="listitem">

       <span class="simpara">
        If this modifier is set, letters in the pattern match both
        upper and lower case letters.
       </span>
      </dd>

    
     <dt class="varlistentry">

      <span class="term"><em class="emphasis">m</em> (<i>PCRE_MULTILINE</i>)</span>

      </dt><dd class="listitem">

       <span class="simpara">
        By default, PCRE treats the subject string as consisting of a
        single &quot;line&quot; of characters (even if it actually contains
        several newlines). The &quot;start of line&quot; metacharacter (^)
        matches only at the start of the string, while the &quot;end of
         line&quot; metacharacter ($) matches only at the end of the
        string, or before a terminating newline (unless
        <em class="emphasis">D</em> modifier is set). This is the same as
        Perl.
       </span>
       <span class="simpara">
        When this modifier is set, the &quot;start of line&quot; and &quot;end of
        line&quot; constructs match immediately following or immediately
        before any newline in the subject string, respectively, as
        well as at the very start and end. This is equivalent to
        Perl&#039;s /m modifier. If there are no &quot;\n&quot; characters in a
        subject string, or no occurrences of ^ or $ in a pattern,
        setting this modifier has no effect.
       </span>
      </dd>

    
     <dt class="varlistentry">

      <span class="term"><em class="emphasis">s</em> (<i>PCRE_DOTALL</i>)</span>

      </dt><dd class="listitem">

       <span class="simpara">
        If this modifier is set, a dot metacharacter in the pattern
        matches all characters, including newlines. Without it,
        newlines are excluded. This modifier is equivalent to Perl&#039;s
        /s modifier.  A negative class such as [^a] always matches a
        newline character, independent of the setting of this
        modifier.
       </span>
      </dd>

    
     <dt class="varlistentry">

      <span class="term"><em class="emphasis">x</em> (<i>PCRE_EXTENDED</i>)</span>

      </dt><dd class="listitem">

       <span class="simpara">
        If this modifier is set, whitespace data characters in the
        pattern are totally ignored except when escaped or inside a
        character class, and characters between an unescaped #
        outside a character class and the next newline character,
        inclusive, are also ignored. This is equivalent to Perl&#039;s /x
        modifier, and makes it possible to include comments inside
        complicated patterns. Note, however, that this applies only
        to data characters. Whitespace characters may never appear
        within special character sequences in a pattern, for example
        within the sequence (?( which introduces a conditional
        subpattern.
       </span>
      </dd>

    
     <dt class="varlistentry">

      <span class="term"><em class="emphasis">e</em> (<i>PREG_REPLACE_EVAL</i>)</span>

      </dt><dd class="listitem">

       <span class="simpara">
        If this modifier is set, <a href="function.preg-replace.php" class="function">preg_replace()</a>
        does normal substitution of backreferences in the
        replacement string, evaluates it as PHP code, and uses the
        result for replacing the search string.
        Single quotes, double quotes, backslashes (<i>\</i>) and NULL chars will
        be escaped by backslashes in substituted backreferences.
       </span>
       <p class="para">
        Only <a href="function.preg-replace.php" class="function">preg_replace()</a> uses this modifier;
        it is ignored by other PCRE functions.
       </p>
      </dd>

    
     <dt class="varlistentry">

      <span class="term"><em class="emphasis">A</em> (<i>PCRE_ANCHORED</i>)</span>

      </dt><dd class="listitem">

       <span class="simpara">
        If this modifier is set, the pattern is forced to be
        &quot;anchored&quot;, that is, it is constrained to match only at the
        start of the string which is being searched (the &quot;subject
        string&quot;).  This effect can also be achieved by appropriate
        constructs in the pattern itself, which is the only way to
        do it in Perl.
       </span>
      </dd>

    
     <dt class="varlistentry">

      <span class="term"><em class="emphasis">D</em> (<i>PCRE_DOLLAR_ENDONLY</i>)</span>

      </dt><dd class="listitem">

       <span class="simpara">
        If this modifier is set, a dollar metacharacter in the pattern
        matches only at the end of the subject string. Without this
        modifier, a dollar also matches immediately before the final
        character if it is a newline (but not before any other
        newlines).  This modifier is ignored if <em class="emphasis">m</em>
        modifier is set. There is no equivalent to this modifier in
        Perl.
       </span>
      </dd>

    
     <dt class="varlistentry">

      <span class="term"><em class="emphasis">S</em></span>

      </dt><dd class="listitem">

       <span class="simpara">
        When a pattern is going to be used several times, it is
        worth spending more time analyzing it in order to speed up
        the time taken for matching. If this modifier is set, then
        this extra analysis is performed. At present, studying a
        pattern is useful only for non-anchored patterns that do not
        have a single fixed starting character.
       </span>
      </dd>

    
     <dt class="varlistentry">

      <span class="term"><em class="emphasis">U</em> (<i>PCRE_UNGREEDY</i>)</span>

      </dt><dd class="listitem">

       <span class="simpara">
        This modifier inverts the &quot;greediness&quot; of the quantifiers so
        that they are not greedy by default, but become greedy if
        followed by <i>?</i>. It is not compatible with Perl. It can also
        be set by a (<i>?U</i>)
        <a href="regexp.reference.internal-options.php" class="link">modifier setting within
        the pattern</a> or by a question mark behind a quantifier (e.g.
        <i>.*?</i>).
       </span>
      </dd>

    
     <dt class="varlistentry">

      <span class="term"><em class="emphasis">X</em> (<i>PCRE_EXTRA</i>)</span>

      </dt><dd class="listitem">

       <span class="simpara">
        This modifier turns on additional functionality of PCRE that
        is incompatible with Perl. Any backslash in a pattern that
        is followed by a letter that has no special meaning causes
        an error, thus reserving these combinations for future
        expansion. By default, as in Perl, a backslash followed by a
        letter with no special meaning is treated as a literal.
        There are at present no other features controlled by this
        modifier.
       </span>
      </dd>

    
     <dt class="varlistentry">

      <span class="term"><em class="emphasis">J</em> (<i>PCRE_INFO_JCHANGED</i>)</span>

      </dt><dd class="listitem">

       <span class="simpara">
        The (?J) internal option setting changes the local <i>PCRE_DUPNAMES</i>
        option. Allow duplicate names for subpatterns.
       </span>
      </dd>

    
     <dt class="varlistentry">

      <span class="term"><em class="emphasis">u</em> (<i>PCRE8</i>)</span>

      </dt><dd class="listitem">

       <span class="simpara">
        This modifier turns on additional functionality of PCRE that
        is incompatible with Perl. Pattern strings are treated as
        UTF-8. This modifier is available from PHP 4.1.0 or greater
        on Unix and from PHP 4.2.3 on win32.
        UTF-8 validity of the pattern is checked since PHP 4.3.5.
       </span>
      </dd>

    
    </dl>
<p>
   </blockquote>
  </p>
</div>
<?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites