downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

MongoRegex::__toString> <MongoRegex
[edit] Last updated: Fri, 18 Sep 2009

view this page in

MongoRegex::__construct

(PECL mongo >= 0.8.1)

MongoRegex::__constructCreates a new regular expression

Описание

MongoRegex::__construct ( string $regex )

Creates a new regular expression.

Параметри

regex

Regular expression string of the form /expr/flags.

Връщани стойности

Returns a new regular expression.

Примери

Example #1 MongoRegex::__construct() example

This example uses a regular expression to query for all documents with a username field matching a regular expression.

<?php

$joe_search 
= new MongoRegex("/j[o0]e/i");
$cursor $collection->find(array("username" => $joe_search));

?>

Вж. също



add a note add a note User Contributed Notes MongoRegex::__construct
calimero at creatixnet dot com 16-May-2012 09:44
AFAICT, as of PHP 5.3.6, this function doesn't work correctly with any delimiter character other than plain slash (/), which is annoying if your pattern looks like a URL or file path for example (which itself may contain slashes you'll have to escape).

One can make use of the print_r($your_mongoregex_object) statement to ensure the pattern is recognized properly.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites