escape.js 255 B

1234567891011
  1. // Thanks to Andrew Clover:
  2. // http://stackoverflow.com/questions/3561493
  3. // /is-there-a-regexp-escape-function-in-javascript
  4. "use strict";
  5. var re = /[-/\\^$*+?.()|[\]{}]/g;
  6. module.exports = function (str) {
  7. return String(str).replace(re, "\\$&");
  8. };