I create a request for mongodb:
app.get('content/:title', function(req, res) { var regexp = new RegExp(req.params.title, 'i'); db.find({ "title": regexp, }).toArray(function(err, array) { res.send(array); }); });
But sometimes the header has a parent column in it. This gives me an error:
SyntaxError: Invalid regular expression: /cat(22/: Unterminated group at new RegExp (unknown source)
The name that is being searched is cat (22).
What is the easiest way to force a regex to take parentheses? Thanks.
Harry source share