regexp-escape-x
ECMAScript proposed RegExp.escape.
See: RegExp.escape
Version: 2.0.2
Author: Xotic750 Xotic750@gmail.com
License: MIT
Copyright: Xotic750
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
var regexpEscape = require('regexp-escape-x');
var str = 'hello. how are you?';
var regex = new RegExp(regexpEscape(str), 'g');
String(regex);