UNPKG

437 BTypeScriptView Raw
1/**
2Escape RegExp special characters.
3
4You can also use this to escape a string that is inserted into the middle of a regex, for example, into a character class.
5
6@example
7```
8import escapeStringRegexp from 'escape-string-regexp';
9
10const escapedString = escapeStringRegexp('How much $ for a 🦄?');
11//=> 'How much \\$ for a 🦄\\?'
12
13new RegExp(escapedString);
14```
15*/
16export default function escapeStringRegexp(string: string): string;