From 7f70d72ea665115a5d8d5ef22e237bb8ce087ce7 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Fri, 24 May 2013 22:18:15 +0000 Subject: [PATCH] Documentation for Regular Expressions (PHP-834) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@330350 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mongo/mongoregex.xml | 47 +++++++++++------------- reference/mongo/mongoregex/construct.xml | 13 ++++--- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/reference/mongo/mongoregex.xml b/reference/mongo/mongoregex.xml index a1cfda6b04..547d816cd2 100644 --- a/reference/mongo/mongoregex.xml +++ b/reference/mongo/mongoregex.xml @@ -17,55 +17,52 @@ More unusually, they can be saved to the database and retrieved. - Mongo recognizes six regular expression flags: + Regular expressions consist of four parts. First a / + as starting delimiter, then then pattern, another / + and finally a string containing flags. + + + + Regular expression pattern + + + + + + + MongoDB recognizes six regular expression flags: - i - - - Case insensitive + i: Case insensitive - m - - - Multiline + m: Multiline - x - - - Can contain comments + x: Can contain comments - l - - - locale + l: locale - s - - - dotall, "." matches everything, including newlines + s: dotall, "." matches everything, including newlines - u - - - match unicode + u: match unicode diff --git a/reference/mongo/mongoregex/construct.xml b/reference/mongo/mongoregex/construct.xml index 1ea5b5ce10..5f5efa04e3 100644 --- a/reference/mongo/mongoregex/construct.xml +++ b/reference/mongo/mongoregex/construct.xml @@ -28,7 +28,7 @@ - Regular expression string of the form /expr/flags. + Regular expression string of the form /expr/flags. @@ -48,14 +48,15 @@ <function>MongoRegex::__construct</function> example - This example uses a regular expression to query for all documents with a username field matching a regular expression. + This example uses a regular expression to query for all documents + with a username field starting (^) with an + l and a vowel ([aeiouy]), + case-insensitive (/i). find(array("username" => $joe_search)); - +$luke_search = new MongoRegex("/^l[aeiouy]/i"); +$cursor = $collection->find(array("username" => $luke_search)); ?> ]]>