# clone-regexp

> Clone and modify a RegExp instance

Latest version **3.0.0** (published 2021-04-08) · MIT license · 0 weekly downloads

> **Better alternative:** Use new RegExp(regexpToCopy) — Consider using a lighter alternative

## Install

```sh
npm install clone-regexp
pnpm add clone-regexp
yarn add clone-regexp
bun add clone-regexp
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2021-04-08 |
| First published | 2014-04-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 1 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | regexp, regex, regular, expression, clone, duplicate, modify, mutate |

## Links

- npm: https://www.npmjs.com/package/clone-regexp
- Repository: https://github.com/sindresorhus/clone-regexp
- Homepage: https://github.com/sindresorhus/clone-regexp#readme
- Issues: https://github.com/sindresorhus/clone-regexp/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/clone-regexp

## Dependencies (1)

- [is-regexp](https://npm.io/package/is-regexp.md) ^3.0.0

## Recent versions

- 3.0.0 (latest) — 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

## README

# 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
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`](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.

---
_Source: https://npm.io/package/clone-regexp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
