Dewsworld
Dewsworld

Reputation: 14063

Finding documents through regex in Mongo

I have a document structure like this one.

> db.urls.find()
{
    "_id" : ObjectId("53d79c7020ba271c80b78b6c"),
    "url" : "http://www.newstoday.com.bd?option=details&news_id=2368296&date=2014-01-27///",
    "priority" : 0.25,
    "date" : ISODate("2014-07-29T13:06:58.745Z"),
    "seen" : 1
}

To find some document using regex I used the following,

> db.urls.find({url: { $regex: 'http://www.newstoday.com.bd?option='} })
>

Which resulted empty. I need some help on the proper regex to use here.

Upvotes: 0

Views: 163

Answers (1)

vks
vks

Reputation: 67988

(?=.*?http:\/\/www\.newstoday\.com\.bd\?.*)(.*)

This will give the document based on the url if that is what you are looking for.

See Demo.

http://regex101.com/r/wE3dU7/1

Upvotes: 2

Related Questions