Possible Duplicate:
Is there a RegExp.escape function in Javascript?
I'm currently using: var keywords = new RegExp(req.params.keywords, 'i');
The catch is, if req.params.keywords == '.*'
, this will match anything, what I want is for it to match .*
literally, as in \.\*\
Is there a more elegant solution than escaping every passed single character with a \
?