mirror of
https://github.com/thangisme/notes.git
synced 2024-11-19 08:45:55 -05:00
1.5 KiB
1.5 KiB
clone-regexp
Clone and modify a RegExp instance
Install
$ npm install --save clone-regexp
Usage
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
API
cloneRegexp(regexp, [options])
regex
Type: regexp
RegExp instance to clone.
options
Type: object
Properties: source
global
ignoreCase
multiline
sticky
unicode
Optionally modify the cloned RegExp instance.
License
MIT © Sindre Sorhus