@cspell/cspell-tools
Version:
Tools to assist with the development of cSpell
9 lines • 300 B
JavaScript
/**
* Escape a string so it can be used as an exact match within a RegExp.
* @param s - string to escape
* @returns - the escaped string.
*/
export function escapeRegEx(s) {
return s.replaceAll(/[|\\{}()[\]^$+*?.]/g, '\\$&').replaceAll('-', '\\x2d');
}
//# sourceMappingURL=escapeRegEx.js.map