Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
cb09f518
Commit
cb09f518
authored
Aug 16, 2017
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-265: Add regex example with character escaping
parent
c1f6e23d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
crud.txt
docs/tutorial/crud.txt
+15
-0
No files found.
docs/tutorial/crud.txt
View file @
cb09f518
...
@@ -375,6 +375,21 @@ An equivalent filter could be constructed using the :query:`$regex` operator:
...
@@ -375,6 +375,21 @@ An equivalent filter could be constructed using the :query:`$regex` operator:
.. seealso:: :manual:`$regex </reference/operator/query/regex>` in the MongoDB manual
.. seealso:: :manual:`$regex </reference/operator/query/regex>` in the MongoDB manual
Although MongoDB's regular expression syntax is not exactly the same as PHP's
:php:`PCRE <manual/en/book.pcre.php>` syntax, :php:`preg_quote() <preg_quote>`
may be used to escape special characters that should be matched as-is. The
following example finds restaurants whose name starts with "(Library)":
.. code-block:: php
<?php
$collection = (new MongoDB\Client)->test->restaurants;
$cursor = $collection->find([
'name' => new MongoDB\BSON\Regex('^' . preg_quote('(Library)')),
]);
.. _php-aggregation:
.. _php-aggregation:
Complex Queries with Aggregation
Complex Queries with Aggregation
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment