UNPKG

@sentry/core

Version:
14 lines (13 loc) • 514 B
// src/vendor/escapeStringForRegex.ts /** * Given a string, escape characters which have meaning in the regex grammar, such that the result is safe to feed to * `new RegExp()`. * * @param regexString The string to escape * @returns An version of the string with all special regex characters escaped */ function escapeStringForRegex(regexString) { return regexString.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d"); } export { escapeStringForRegex }; //# sourceMappingURL=escapeStringForRegex.js.map