Skip to content

Instantly share code, notes, and snippets.

@Nixinova
Created September 9, 2021 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nixinova/891052ed97345495fdc9f14fea852cff to your computer and use it in GitHub Desktop.
Save Nixinova/891052ed97345495fdc9f14fea852cff to your computer and use it in GitHub Desktop.
Regex escape function
export default const escapeRegex = (str: string): string => str.replace(/[.*+?^/${}()|[\]\\]/g, '\\$&');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment