4
1

escape.js 258 B

123456789
  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) { return String(str).replace(re, '\\$&'); };