1'use strict'; 2 3var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; 4 5module.exports = function (str) { 6 if (typeof str !== 'string') { 7 throw new TypeError('Expected a string'); 8 } 9 10 return str.replace(matchOperatorsRe, '\\$&'); 11}; 12