I need to remove single quotation marks from
var test = '\/'+val.text+'\/i';
in order to do a mongodb search like db.document.find({field:test}) That is, If val.text is 'hello', the find should be
db.document.find({field:/hello/i})
and not
db.document.find({field:'/hello/i'})
which wont find any field with the substring 'hello' How do I do that without using eval(test) ?