/** * Escape string for special regular expression characters. */ function escapeRegExp(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string } module.exports = { escapeRegExp, };