Files
omnivore/packages/liqe/src/escapeRegexString.ts
2023-12-07 18:47:25 +08:00

9 lines
220 B
TypeScript

const ESCAPE_RULE = /[$()*+.?[\\\]^{|}]/g;
const DASH_RULE = /-/g;
export const escapeRegexString = (subject: string): string => {
return subject
.replace(ESCAPE_RULE, '\\$&')
.replace(DASH_RULE, '\\x2d');
};