MongoRegex::__construct

(PECL mongo >= 0.8.1)

MongoRegex::__constructCreates a new regular expression

Описание

public MongoRegex::__construct ( string $regex )

Creates a new regular expression.

Список параметров

regex

Regular expression string of the form /expr/flags.

Возвращаемые значения

Returns a new regular expression.

Примеры

Пример #1 MongoRegex::__construct() example

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).

<?php
$luke_search 
= new MongoRegex("/^l[aeiouy]/i");
$cursor $collection->find(array("username" => $luke_search));
?>

Смотрите также

Коментарии

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.
2012-05-16 12:44:03
http://php5.kiev.ua/manual/ru/mongoregex.construct.html

    Поддержать сайт на родительском проекте КГБ