UNPKG

fast-escape-regexp

Version:

Fastest, plain JavaScript-based, regexp escaping library for JavaScript, works in both Node.js and browser.

12 lines (10 loc) 657 B
/** * Escape characters with special meaning either inside or outside character sets. * Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar. * * When the `unicodeMode` is `true` (default), the `-` character is escaped as `\x2d` to ensure compatibility with Unicode patterns, PCRE, and MongoDB. * * You should only disable this option if you are escaping regular expressions that will later be consumed by runtimes w/o unicode flag support. */ declare function escapeRegexp(str: string, unicodeMode?: boolean): string; export { escapeRegexp };