https://github.com/xotic750/regexp-escape-x
regexpEscape module.
https://github.com/xotic750/regexp-escape-x
browser ecmascript nodejs regexp-escape
Last synced: about 2 months ago
JSON representation
regexpEscape module.
- Host: GitHub
- URL: https://github.com/xotic750/regexp-escape-x
- Owner: Xotic750
- License: mit
- Created: 2016-01-20T22:57:50.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:54:29.000Z (over 3 years ago)
- Last Synced: 2025-09-29T19:45:21.415Z (9 months ago)
- Topics: browser, ecmascript, nodejs, regexp-escape
- Language: JavaScript
- Size: 2.29 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## regexp-escape-x
ECMAScript proposed RegExp.escape.
**See**: [RegExp.escape](https://github.com/benjamingr/RegExp.escape)
### `module.exports(string)` ⇒ string ⏏
Method to safely escape `RegExp` special tokens for use in `new RegExp`.
**Kind**: Exported function
**Returns**: string - The escaped string.
**Throws**:
- TypeError If string is null or undefined or not coercible.
| Param | Type | Description |
| ------ | ------------------- | ------------------------- |
| string | string | The string to be escaped. |
**Example**
```js
import regexpEscape from 'regexp-escape-x';
const str = 'hello. how are you?';
const regex = new RegExp(regexpEscape(str), 'g');
console.log(String(regex)); // '/hello\. how are you\?/g'
```