I have a document in MongoDB with a regex attribute
{
_id: ObjectId("516023189732da20ce000004"),
regex: /^(my|your)\s+regex$/
}
and I need to retrieve this document with something like db.col.find({regex: 'your regex'}) and db.col.find({regex: 'my regex'}).
In MySQL I'd do: SELECT * FROM table WHERE 'my regex' REGEXP table.regex. How can I achieve this in MongoDB?
db.col.find({regex: '/^[my|your]\s+regex$/'})work since it isn't outisde of quotes and it isn't a regexp object?my regexoryour regex, butm regexory regexor| regex&c. If it had to match withmy regexit would be/^(my|your)\s+regex$/. Am I missing something?