https://github.com/trapcodeio/escape-string-regexp-node
Escape Regexp String Function written in typescript for Nodejs
https://github.com/trapcodeio/escape-string-regexp-node
Last synced: 7 months ago
JSON representation
Escape Regexp String Function written in typescript for Nodejs
- Host: GitHub
- URL: https://github.com/trapcodeio/escape-string-regexp-node
- Owner: trapcodeio
- Created: 2021-11-19T17:17:01.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-19T17:57:13.000Z (over 3 years ago)
- Last Synced: 2024-11-29T08:42:16.138Z (7 months ago)
- Language: TypeScript
- Size: 13.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# escape-string-regexp-node
> Escape RegExp special characters in Node.js
Written originally by [sindresorhus (escape-string-regexp)](https://github.com/sindresorhus/escape-string-regexp)
## Install
```
$ npm install escape-string-regexp-node
```## Usage
```ts
const escapeRegexp = require("escape-string-regexp-node");
// Typescript
import escapeRegexp from 'escape-string-regexp-node';const escapedString = escapeRegexp('How much $ for a 🦄?');
//=> 'How much \\$ for a 🦄\\?'new RegExp(escapedString);
```You can also use this to escape a string that is inserted into the middle of a regex, for example, into a character
class.---