MongoDB reverse regex

前端 未结 1 1353
借酒劲吻你
借酒劲吻你 2020-11-27 08:35

I have a document in MongoDB with a regex attribute

    {
        _id: ObjectId(\"516023189732da20ce000004\"),
        regex: /^(my|your)\\s+regex$/
    }


        
相关标签:
1条回答
  • 2020-11-27 09:19

    You can use the $where operator in the following fashion:

    db.col.find({$where: "\"my regex\".match(this.regex)"})
    
    0 讨论(0)
提交回复
热议问题