reginald
v1.0.0
Published
Clone and modify a RegExp instance, including removing, prepending, appending & replacing the source
Downloads
1
Maintainers
Readme
reginald
Clone and modify a RegExp instance, including removing, prepending, appending & replacing the source
Reginald is based on clone-regexp by sindresorhus. Reginald adds source manipulation functionality on top of what clone-regexp offered
Install
$ npm i -S reginald
Usage
var reggie = require('reginald');
var re = /[a-z]/gi;
reggie(re);
//=> /[a-z]/gi
reggie(re) === re;
//=> false
reggie(re, {global: false});
//=> /[a-z]/i
reggie(re, {multiline: true});
//=> /[a-z]/gim
reggie(re, {source: 'wombat'});
//=> /wombat/gi
reggie(/a/, {replace: ['a','b']})
//=> /b/
reggie(/ab/, {remove: 'a'})
//=> /b/
reggie(/a/, {prepend: 'b'})
//=> /ba/
reggie(/a/, {append: 'b'})
//=> /ab/
reggie(/ab/, {remove: 'b'})
//=> /a/
API
reggie(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 MIT © James Womack