在我的attributes
密钥中,我想在Special
和latenight : True
的数组记录中找到。
"attributes" : [ "Alcohol: none", "BikeParking: True", "Special: {'dessert': False, 'latenight': False, 'lunch': False, 'dinner': False, 'breakfast': False, 'brunch': False}" ]
到目前为止,这是我所拥有的db.restaurant.find({ attributes: {$in :[/^Special/]} });
。但我不知道从那里去哪里。我希望正则表达式也包含latenight : True
。
答案 0 :(得分:1)
您正在寻找的正则表达式是
/^Special.*'latenight': True/
请参阅regex demo。
<强>详情
^
- 字符串开头Special
- 文字字符串.*
- 除了换行符之外的任何0 +字符,尽可能多'latenight': True
- 文字子字符串。请注意,您可以使用\s+
替换文字空间以匹配任何1个以上的空格字符。