<?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 => 'zh',
  ),
  'this' => 
  array (
    0 => 'regexp.reference.delimiters.php',
    1 => '分隔符',
    2 => '分隔符',
  ),
  'up' => 
  array (
    0 => 'reference.pcre.pattern.syntax.php',
    1 => 'PCRE 正则语法',
  ),
  'prev' => 
  array (
    0 => 'regexp.introduction.php',
    1 => '简介',
  ),
  'next' => 
  array (
    0 => 'regexp.reference.meta.php',
    1 => '元字符',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    '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">分隔符</h2>
  <p class="para">
  当使用 PCRE 函数的时候，模式需要由<em>分隔符</em>闭合包裹。
   分隔符可以是任意非字母数字、非反斜线、非空白字符。
   静默忽略合法分隔符之前的空白字符。
  </p>
  <p class="para">
  经常使用的分隔符是正斜线(<code class="literal">/</code>)、hash符号(<code class="literal">#</code>)
  以及取反符号(<code class="literal">~</code>)。下面的例子都是使用合法分隔符的模式。
   <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">
  如果需要在正则模式内匹配分隔符，必须使用反斜线转义。如果分隔符经常在
   正则模式内出现， 最好使用其他分隔符以便提高可读性。
   <div class="informalexample">
    <div class="example-contents">
<div class="annotation-interactive cdata"><pre>
/http:\/\//
#http://#
</pre></div>
    </div>

   </div>
   需要将一个字符串放入模式中使用时，可以用 <span class="function"><a href="function.preg-quote.php" class="function">preg_quote()</a></span> 函数对其进行
   转义，它的第二个参数(可选)可以用于指定需要被转义的分隔符。
  </p>
  <p class="para">
  可以在结束分隔符后面增加<a href="reference.pcre.pattern.modifiers.php" class="link">模式修饰符</a>。
  下面的例子是一个大小写不敏感的匹配：
   <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); ?>