Sha256: 4450d90264a2360e697642ad8d359ef0434f5047fabd0c28c39e21075ad3a289

Contents?: true

Size: 1.74 KB

Versions: 24

Compression:

Stored size: 1.74 KB

Contents

# clone-regexp [![Build Status](https://travis-ci.org/sindresorhus/clone-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/clone-regexp)

> Clone and modify a [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) instance


## Install

```
$ npm install clone-regexp
```


## Usage

```js
const cloneRegexp = require('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`<br>
Properties: [`source`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source) [`global`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global) [`ignoreCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase) [`multiline`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline) [`dotAll`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll) [`sticky`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky) [`unicode`](http://norbertlindenberg.com/2012/05/ecmascript-supplementary-characters/#RegExp) [`lastIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex)

Optionally modify the cloned `RegExp` instance.


## License

MIT © [Sindre Sorhus](https://sindresorhus.com)

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 node_modules/clone-regexp/readme.md
trusty-cms-5.0.7 node_modules/clone-regexp/readme.md
trusty-cms-5.0.6 node_modules/clone-regexp/readme.md
trusty-cms-5.0.5 node_modules/clone-regexp/readme.md
trusty-cms-5.0.4 node_modules/clone-regexp/readme.md
trusty-cms-5.0.3 node_modules/clone-regexp/readme.md
trusty-cms-5.0.2 node_modules/clone-regexp/readme.md
trusty-cms-5.0.1 node_modules/clone-regexp/readme.md
trusty-cms-4.3.5 node_modules/clone-regexp/readme.md
trusty-cms-5.0.0 node_modules/clone-regexp/readme.md
trusty-cms-4.3.4 node_modules/clone-regexp/readme.md
trusty-cms-4.3.3 node_modules/clone-regexp/readme.md
trusty-cms-4.3.2 node_modules/clone-regexp/readme.md
trusty-cms-4.3.1 node_modules/clone-regexp/readme.md
trusty-cms-4.3 node_modules/clone-regexp/readme.md
trusty-cms-4.2.3 node_modules/clone-regexp/readme.md
trusty-cms-4.2.2 node_modules/clone-regexp/readme.md
trusty-cms-4.2.1 node_modules/clone-regexp/readme.md
trusty-cms-4.2 node_modules/clone-regexp/readme.md
trusty-cms-4.1.9 node_modules/clone-regexp/readme.md