[DOCS-4265] Comment on: "manual/reference/operator/query/regex.txt" Created: 29/Oct/14  Updated: 16/Mar/15  Resolved: 05/Nov/14

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: v1.3.13

Type: Bug Priority: Major - P3
Reporter: Chris Findlay Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: http://docs.mongodb.org/manual/reference/operator/query/regex/
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36
Referrer: https://www.google.co.nz/
Screen Resolution: 1920 x 1080
repo: docs
source: reference/operator/query/regex


Participants:
Days since reply: 9 years, 14 weeks, 5 days ago

 Description   

This page mentions that Mongo uses PCRE, and specifies that you must use $regex over /.../ to pass PCRE-only options.

However, it does not mention what version of PCRE is used, nor what build options were used (e.g. UTF-8, UTF-16 etc), and does not mention that you also need to use $regex if your pattern contains features that PCRE supports but JS does not.



 Comments   
Comment by Kay Kim (Inactive) [ 07/Nov/14 ]

Published the various fixes today : )

Comment by Kay Kim (Inactive) [ 06/Nov/14 ]

Thanks Chris –
we have corrected the heading last week (see the git commit below), but we haven't published the manual with the fix yet.
https://github.com/mongodb/docs/commit/7378787c712b4e941fe145f7c498372f3940ebfe

Comment by Chris Findlay [ 05/Nov/14 ]

I just noticed something else on the current live page:
http://docs.mongodb.org/manual/reference/operator/query/regex/#x-and-m-options
The heading says x and m, but the text and the examples say x and s.

Comment by Githook User [ 05/Nov/14 ]

Author:

{u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}

Message: DOCS-4265 pcre regex pattern
Branch: master
https://github.com/mongodb/docs/commit/9b973844681e39e76b3c4f2b5025a4f5afe8af56

Comment by Kay Kim (Inactive) [ 04/Nov/14 ]

no worries. just wanted to double check : )

Comment by Chris Findlay [ 03/Nov/14 ]

I can't find my example now that was failing. I must have had a typo in it as I can't replicate that problem either.

Comment by Kay Kim (Inactive) [ 03/Nov/14 ]

Hi Chris –
I'm working on updating the $regex page.

But regarding the comment about the aggregation and $options, I am able to use the $options in the $match phase:

 
> db.products.find()
{ "_id" : 1, "item" : "book" }
{ "_id" : 2, "item" : "boots" }
{ "_id" : 3, "item" : "BOAT" }
> db.products.aggregate( [ { $match: { item: { $regex: "bo", $options: "i" } } } ] )
{ "_id" : 1, "item" : "book" }
{ "_id" : 2, "item" : "boots" }
{ "_id" : 3, "item" : "BOAT" }
> db.products.aggregate( [ { $match: { item: { $regex: /bo/, $options: "i" } } } ] )
{ "_id" : 1, "item" : "book" }
{ "_id" : 2, "item" : "boots" }
{ "_id" : 3, "item" : "BOAT" }
> db.products.aggregate( [ { $match: { item: { $regex: /bo/i } } } ] )
{ "_id" : 1, "item" : "book" }
{ "_id" : 2, "item" : "boots" }
{ "_id" : 3, "item" : "BOAT" }
> db.products.aggregate( [ { $match: { item: { $regex: /bo/ } } } ] )
{ "_id" : 1, "item" : "book" }
{ "_id" : 2, "item" : "boots" }
 

Comment by Chris Findlay [ 31/Oct/14 ]

Additionally, it seems I can't use

{ $regex: "pattern", $options: "i" }

inside of an aggregate $match but if I leave out the $options I can. This is not mentioned anywhere I've looked, neither on this page nor on the aggregate docs pages.

Generated at Thu Feb 08 07:47:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.