clone-regexp
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

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.

Package Sidebar

Install

npm i clone-regexp

Weekly Downloads

1,453,906

Version

3.0.0

License

MIT

Unpacked Size

6.27 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus