rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
18 lines • 548 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.regexEscapeRegex = void 0;
/**
* @public
* Escapes RegExp special characters in strings.
*
* @returns The escaped string.
*
* @remarks
* See {@link regexEscapeRegex}.
*/
function regexEscapeRegex(value) {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
return value.replace(/[.*+\-?^${}()|[\]\\]/g, `\\$&`);
}
exports.regexEscapeRegex = regexEscapeRegex;
//# sourceMappingURL=regex-escape-regex.js.map