clone-regexp

Clone and modify a RegExp instance

MIT 10 个版本
安装
npm install clone-regexp
yarn add clone-regexp
pnpm add clone-regexp
bun add clone-regexp
README

clone-regexp

Clone and modify a RegExp instance

Install

$ npm install clone-regexp

Usage

import cloneRegexp from 'clone-regexp';

const regex = /[a-z]/gi;

cloneRegexp(regex);
//=> /[a-z]/gi

cloneRegexp(regex) === regex;
//=> false

cloneRegexp(regex, {global: false});
//=> /[a-z]/i

cloneRegexp(regex, {multiline: true});
//=> /[a-z]/gim

cloneRegexp(regex, {source: 'unicorn'});
//=> /unicorn/gi

API

cloneRegexp(regexp, options?)

regex

Type: RegExp

Regex to clone.

options

Type: object
Properties: source global ignoreCase multiline dotAll sticky unicode lastIndex

Optionally modify the cloned RegExp instance.

版本列表
3.0.0 2021-04-08
2.2.0 2019-04-16
2.1.0 2018-05-08
2.0.0 2018-05-03
1.0.1 2018-03-23
1.0.0 2014-08-13
0.1.4 2014-06-14
0.1.3 2014-06-11
0.1.2 2014-04-29
0.1.1 2014-04-16