12 lines
219 B
JavaScript
12 lines
219 B
JavaScript
|
|
||
|
/**
|
||
|
* Escape regexp special characters in `str`.
|
||
|
*
|
||
|
* @param {String} str
|
||
|
* @return {String}
|
||
|
* @api public
|
||
|
*/
|
||
|
|
||
|
module.exports = function(str){
|
||
|
return String(str).replace(/([.*+?=^!:${}()|[\]\/\\])/g, '\\$1');
|
||
|
};
|