<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/pcre.xml, last change in rev 1.2 -->
  <refentry id="function.preg-quote">
   <refnamediv>
    <refname>preg_quote</refname>
    <refpurpose>Quote regular expression characters</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>preg_quote</methodname>
      <methodparam><type>string</type><parameter>str</parameter></methodparam>
     <methodparam choice="opt"><type>string</type><parameter>delimiter</parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>preg_quote</function> takes <parameter>str</parameter>
     and puts a backslash in front of every character that is part of
     the regular expression syntax.  This is useful if you have a
     run-time string that you need to match in some text and the
     string may contain special regex characters.
    </para>
    <para>
     If the optional <parameter>delimiter</parameter> is specified, it
     will also be escaped.  This is useful for escaping the delimiter
     that is required by the PCRE functions. The / is the most commonly
     used delimiter.</para>
    <para>
     The special regular expression characters are:
     <literal>. \\ + * ? [ ^ ] $ ( ) { } = ! &lt; &gt; | :</literal>
    </para>
    <para>
     <example>
      <title><function>preg_quote</function> example</title>
      <programlisting role="php">
<![CDATA[
<?php
$keywords = "$40 for a g3/400";
$keywords = preg_quote($keywords, "/");
echo $keywords; // returns \$40 for a g3\/400
?>
]]>
      </programlisting>
     </example>
    </para>
    <para>
     <example>
      <title>Italicizing a word within some text</title>
      <programlisting role="php">
<![CDATA[
<?php
// In this example, preg_quote($word) is used to keep the
// asterisks from having special meaning to the regular
// expression.

$textbody = "This book is *very* difficult to find.";
$word = "*very*";
$textbody = preg_replace ("/" . preg_quote($word) . "/",
                          "<i>" . $word . "</i>",
                          $textbody);
?>
]]>
      </programlisting>
     </example>
    </para>

    &note.bin-safe;

   </refsect1>
  </refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->