clone-regexp

Clone and modify a RegExp instance

clone-regexp

Clone and modify a RegExp instance

$ npm install --save clone-regexp
var cloneRegexp = require('clone-regexp');
var re = /[a-z]/gi;
 
cloneRegexp(re);
//=> /[a-z]/gi 
 
cloneRegexp(re) === re;
//=> false 
 
cloneRegexp(re, {global: false});
//=> /[a-z]/i 
 
cloneRegexp(re, {multiline: true});
//=> /[a-z]/gim 
 
cloneRegexp(re, {source: 'unicorn'});
//=> /unicorn/gi 

Type: regexp

RegExp instance to clone.

Type: object
Properties: source global ignoreCase multiline sticky unicode

Optionally modify the cloned RegExp instance.

MIT © Sindre Sorhus