RegExp.escape
Simon Willison's Weblog:
Escaping regular expression characters in JavaScript
Performance/Compatibility Test