【发布时间】:2016-01-14 15:09:12
【问题描述】:
我的代码是
var search_element=Session.get("search_string");
var adc="/"+search_element+"*/";
console.log(adc);
return Polls_Coll.find({question:{$regex:adc}});
为什么它不起作用
如果我给了
Polls_Coll.find({question:{$regex:/Best*/}});
conslow 它正在工作,如果我用值(search_element)替换正则表达式,它就不起作用。我认为它正在像这样替换
Polls_Coll.find({question:{$regex:"/Best*/"}});(with quotes "/Best*/")
这是主要问题吗?还是我犯了什么愚蠢的错误??
【问题讨论】: