Source

string/escapeSpecialCharacters.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Escape special characters using regexp.
 *
 * Reference: https://stackoverflow.com/questions/3115150/how-to-escape-regular-expression-special-characters-using-javascript
 *
 * @param text The text to escape
 * @category string
 * @module escapeSpecialCharacters
 */
function escapeSpecialCharacters(text) {
    return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
exports.default = escapeSpecialCharacters;