2016-10-10 03:43:44 +02:00
|
|
|
# escape-string-regexp [![Build Status](https://travis-ci.org/sindresorhus/escape-string-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-regexp)
|
|
|
|
|
|
|
|
> Escape RegExp special characters
|
|
|
|
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
2016-11-03 01:33:53 +01:00
|
|
|
```sh
|
2016-10-10 03:43:44 +02:00
|
|
|
$ npm install --save escape-string-regexp
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```js
|
2016-11-03 01:33:53 +01:00
|
|
|
var escapeStringRegexp = require('escape-string-regexp');
|
2016-10-10 03:43:44 +02:00
|
|
|
|
2016-11-03 01:33:53 +01:00
|
|
|
var escapedString = escapeStringRegexp('how much $ for a unicorn?');
|
|
|
|
//=> how much \$ for a unicorn\?
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
new RegExp(escapedString);
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
MIT © [Sindre Sorhus](http://sindresorhus.com)
|