mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Documentation for Regular Expressions (PHP-834)
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@330350 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
1fc0b05670
commit
7f70d72ea6
2 changed files with 29 additions and 31 deletions
|
@ -17,55 +17,52 @@
|
|||
More unusually, they can be saved to the database and retrieved.
|
||||
</para>
|
||||
<para>
|
||||
Mongo recognizes six regular expression flags:
|
||||
Regular expressions consist of four parts. First a <literal>/</literal>
|
||||
as starting delimiter, then then pattern, another <literal>/</literal>
|
||||
and finally a string containing flags.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Regular expression pattern</title>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
/pattern/flags
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
MongoDB recognizes six regular expression flags:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>i</literal>
|
||||
</para>
|
||||
<para>
|
||||
Case insensitive
|
||||
<literal>i</literal>: Case insensitive
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>m</literal>
|
||||
</para>
|
||||
<para>
|
||||
Multiline
|
||||
<literal>m</literal>: Multiline
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>x</literal>
|
||||
</para>
|
||||
<para>
|
||||
Can contain comments
|
||||
<literal>x</literal>: Can contain comments
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>l</literal>
|
||||
</para>
|
||||
<para>
|
||||
locale
|
||||
<literal>l</literal>: locale
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>s</literal>
|
||||
</para>
|
||||
<para>
|
||||
dotall, "." matches everything, including newlines
|
||||
<literal>s</literal>: dotall, "." matches everything, including newlines
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>u</literal>
|
||||
</para>
|
||||
<para>
|
||||
match unicode
|
||||
<literal>u</literal>: match unicode
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Regular expression string of the form /expr/flags.
|
||||
Regular expression string of the form <literal>/expr/flags</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
@ -48,14 +48,15 @@
|
|||
<para>
|
||||
<example>
|
||||
<title><function>MongoRegex::__construct</function> example</title>
|
||||
<para>This example uses a regular expression to query for all documents with a username field matching a regular expression.</para>
|
||||
<para>This example uses a regular expression to query for all documents
|
||||
with a username field starting (<literal>^</literal>) with an
|
||||
<literal>l</literal> and a vowel (<literal>[aeiouy]</literal>),
|
||||
case-insensitive (<literal>/i</literal>).</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$joe_search = new MongoRegex("/j[o0]e/i");
|
||||
$cursor = $collection->find(array("username" => $joe_search));
|
||||
|
||||
$luke_search = new MongoRegex("/^l[aeiouy]/i");
|
||||
$cursor = $collection->find(array("username" => $luke_search));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
Loading…
Reference in a new issue