Escapes all control characters in a JavaScript regular expression.