2014-07-07 16:49:11 -07:00

9 lines
183 B
JavaScript

'use strict';
module.exports = function (str) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string');
}
return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
};