escapeRegExp.js 225 B

123456789101112
  1. var toString = require('../lang/toString');
  2. /**
  3. * Escape RegExp string chars.
  4. */
  5. function escapeRegExp(str) {
  6. return toString(str).replace(/\W/g,'\\$&');
  7. }
  8. module.exports = escapeRegExp;