mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Closes #50232.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@292344 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
ded1438f33
commit
e6bb3e8635
1 changed files with 56 additions and 0 deletions
|
@ -26,6 +26,62 @@
|
|||
itself.
|
||||
</para>
|
||||
</section>
|
||||
<section xml:id="regexp.reference.delimiters">
|
||||
<title>Delimiters</title>
|
||||
<para>
|
||||
When using the PCRE functions, it is required that the pattern is enclosed
|
||||
in <emphasis>delimiters</emphasis>. A delimiter can be any non-alphanumeric,
|
||||
non-whitespace character.
|
||||
</para>
|
||||
<para>
|
||||
Often used delimiters are forward slashes (<literal>/</literal>), hash
|
||||
signs (<literal>#</literal>) and tildes (<literal>~</literal>). The
|
||||
following are all examples of valid delimited patterns.
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
/foo bar/
|
||||
#^[^0-9]$#
|
||||
+php+
|
||||
%[a-zA-Z0-9_-]%
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
If the delimiter needs to be matched inside the pattern it will have to be
|
||||
escaped using a backslash. If the delimiter appears often inside the
|
||||
pattern, it is a good idea choosing another delimiter to increase
|
||||
readability.
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
/http:\/\//
|
||||
#http://#
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
The <function>preg_quote</function> may be used to inject a string into
|
||||
a pattern and its second parameter allows to specify the chosen delimiter
|
||||
so it will be escaped as well.
|
||||
</para>
|
||||
<para>
|
||||
In addition to the aforementioned delimiters, it is also possible using
|
||||
bracket style delimiters where the opening and closing brackets are the
|
||||
starting and ending delimiter, respectively.
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
{this is a pattern}
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
You may add <link linkend="reference.pcre.pattern.modifiers">pattern
|
||||
modifiers</link> after the ending delimiter. The following is an example
|
||||
of case-insensitive matching:
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
#[a-z]#i
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
</section>
|
||||
<section xml:id="regexp.reference.meta">
|
||||
<title>Meta-characters</title>
|
||||
<para>
|
||||
|
|
Loading…
Reference in a new issue