<?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.comments.php',
    1 => 'Comments',
    2 => 'Comments',
  ),
  'up' => 
  array (
    0 => 'reference.pcre.pattern.syntax.php',
    1 => 'PCRE regex syntax',
  ),
  'prev' => 
  array (
    0 => 'regexp.reference.conditional.php',
    1 => 'Conditional subpatterns',
  ),
  'next' => 
  array (
    0 => 'regexp.reference.recursive.php',
    1 => 'Recursive patterns',
  ),
  '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.comments" class="section">
  <h2 class="title">Comments</h2>
  <p class="para">
   The sequence (?# marks the start of a comment which
   continues up to the next closing parenthesis. Nested
   parentheses are not permitted. The characters that make up a
   comment play no part in the pattern matching at all.
  </p>
  <p class="para">
   If the <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_EXTENDED</a>
   option is set, an unescaped # character outside a character class
   introduces a comment that continues up to the next newline character
   in the pattern.
  </p>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 Usage of comments in PCRE pattern</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$subject </span><span style="color: #007700">= </span><span style="color: #DD0000">'test'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* (?# can be used to add comments without enabling PCRE_EXTENDED */<br /></span><span style="color: #0000BB">$match </span><span style="color: #007700">= </span><span style="color: #0000BB">preg_match</span><span style="color: #007700">(</span><span style="color: #DD0000">'/te(?# this is a comment)st/'</span><span style="color: #007700">, </span><span style="color: #0000BB">$subject</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$match</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Whitespace and # is treated as part of the pattern unless PCRE_EXTENDED is enabled */<br /></span><span style="color: #0000BB">$match </span><span style="color: #007700">= </span><span style="color: #0000BB">preg_match</span><span style="color: #007700">(</span><span style="color: #DD0000">'/te   #~~~~<br />st/'</span><span style="color: #007700">, </span><span style="color: #0000BB">$subject</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$match</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* When PCRE_EXTENDED is enabled, all whitespace data characters and anything<br />   that follows an unescaped # on the same line is ignored */<br /></span><span style="color: #0000BB">$match </span><span style="color: #007700">= </span><span style="color: #0000BB">preg_match</span><span style="color: #007700">(</span><span style="color: #DD0000">'/te    #~~~~<br />st/x'</span><span style="color: #007700">, </span><span style="color: #0000BB">$subject</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$match</span><span style="color: #007700">);</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive cdata"><pre>
int(1)
int(0)
int(1)
</pre></div>
    </div>
   </div>
  </p>
 </div><?php manual_footer($setup); ?>