como usar o escapeRegExp no javascript es6
January 04, 2020
Escapes a string to use in a regular expression.
Use String.prototype.replace()
to escape special characters.
const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
escapeRegExp('(test)'); // \\(test\\)