regexp-escape-x

ECMAScript proposed RegExp.escape.

MIT 46 个版本
安装
npm install regexp-escape-x
yarn add regexp-escape-x
pnpm add regexp-escape-x
bun add regexp-escape-x
README

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

regexp-escape-x

ECMAScript proposed RegExp.escape.

See: 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

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'
版本列表
3.1.2 2019-08-28
3.1.1 2019-08-20
3.1.0 2019-08-14
3.0.27 2019-07-31
3.0.26 2019-07-27
3.0.25 2019-07-27
3.0.24 2019-07-26
3.0.23 2019-07-25
3.0.22 2019-07-24
3.0.21 2019-07-24
3.0.20 2019-07-23
3.0.19 2019-07-22
3.0.18 2019-07-21
3.0.17 2019-07-21
3.0.16 2019-07-19
3.0.15 2019-07-18
3.0.14 2019-07-18
3.0.13 2019-07-17
3.0.12 2019-07-17
3.0.11 2019-07-17
3.0.10 2019-07-17
3.0.9 2019-07-16
3.0.8 2019-07-16
3.0.7 2019-07-16
3.0.6 2019-07-15
3.0.5 2019-07-15
3.0.4 2019-07-14
3.0.3 2019-07-13
3.0.2 2019-07-13
3.0.1 2019-07-12
3.0.0 2019-07-10
2.0.2 2018-02-24
2.0.1 2018-02-24
2.0.0 2017-09-27
1.4.1 2017-09-01
1.4.0 2017-07-10
1.3.0 2017-07-02
1.2.0 2017-03-28
1.1.1 2017-03-27
1.1.0 2017-02-18
1.0.5 2016-02-15
1.0.4 2016-02-13
1.0.3 2016-02-03
1.0.2 2016-01-25
1.0.1 2016-01-24
1.0.0 2016-01-20