<?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.delimiters.php',
    1 => 'Delimiters',
    2 => 'Delimiters',
  ),
  'up' => 
  array (
    0 => 'reference.pcre.pattern.syntax.php',
    1 => 'PCRE regex syntax',
  ),
  'prev' => 
  array (
    0 => 'regexp.introduction.php',
    1 => 'Introduction',
  ),
  'next' => 
  array (
    0 => 'regexp.reference.meta.php',
    1 => 'Meta-characters',
  ),
  '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.delimiters" class="section">
  <h2 class="title">Delimiters</h2>
  <p class="para">
   When using the PCRE functions, it is required that the pattern is enclosed
   by <em>delimiters</em>. A delimiter can be any non-alphanumeric,
   non-backslash, non-whitespace character.
   Leading whitespace before a valid delimiter is silently ignored.
  </p>
  <p class="para">
   Often used delimiters are forward slashes (<code class="literal">/</code>), hash
   signs (<code class="literal">#</code>) and tildes (<code class="literal">~</code>). The
   following are all examples of valid delimited patterns.
   <div class="informalexample">
    <div class="example-contents">
<div class="annotation-interactive cdata"><pre>
/foo bar/
#^[^0-9]$#
+php+
%[a-zA-Z0-9_-]%
</pre></div>
    </div>

   </div>
  </p>
  <p class="para">
   It is also possible to use
   bracket style delimiters where the opening and closing brackets are the
   starting and ending delimiter, respectively. <code class="literal">()</code>,
   <code class="literal">{}</code>, <code class="literal">[]</code> and <code class="literal">&lt;&gt;</code>
   are all valid bracket style delimiter pairs.
   <div class="informalexample">
    <div class="example-contents">
<div class="annotation-interactive cdata"><pre>
(this [is] a (pattern))
{this [is] a (pattern)}
[this [is] a (pattern)]
&lt;this [is] a (pattern)&gt;
</pre></div>
    </div>

   </div>
   Bracket style delimiters do not need to be escaped when they are used as meta
   characters within the pattern, but as with other delimiters they must be
   escaped when they are used as literal characters.
  </p>
  <p class="para">
   If the delimiter needs to be matched inside the pattern it must be
   escaped using a backslash. If the delimiter appears often inside the
   pattern, it is a good idea to choose another delimiter in order to increase
   readability.
   <div class="informalexample">
    <div class="example-contents">
<div class="annotation-interactive cdata"><pre>
/http:\/\//
#http://#
</pre></div>
    </div>

   </div>
   The <span class="function"><a href="function.preg-quote.php" class="function">preg_quote()</a></span> function may be used to escape a string
   for injection into a pattern and its optional second parameter may be used
   to specify the delimiter to be escaped.
  </p>
  <p class="para">
   You may add <a href="reference.pcre.pattern.modifiers.php" class="link">pattern
   modifiers</a> after the ending delimiter. The following is an example
   of case-insensitive matching:
   <div class="informalexample">
    <div class="example-contents">
<div class="annotation-interactive cdata"><pre>
#[a-z]#i
</pre></div>
    </div>

   </div>
  </p>
 </div><?php manual_footer($setup); ?>