MongoRegex::__construct

Creates a new regular expression

Hinweis:

This extension that defines this method is deprecated. Instead, the MongoDB extension should be used. Alternatives to this method include:

  • MongoDB\BSON\Regex::__construct

Beschreibung

public MongoRegex::__construct ( string $regex )

Creates a new regular expression.

Parameter-Liste

regex

Regular expression string of the form /expr/flags.

Rückgabewerte

Returns a new regular expression.

Beispiele

Beispiel #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));
?>

Siehe auch

  • MongoRegex::__toString