join-regexp
v1.0.0
Published
utility to join regexps together
Downloads
1
Readme
Install
$ npm i join-regexp
Example
import { joinRegExp } from 'join-regexp'
const regexp = joinRegExp(
[
/(?<ids>[a-z_][a-z0-9_]*)/gm, // <= individual flags are stripped
/(?<num>\d+(\.\d*)?)/,
/(?<ops>[-~+*/%=<>?!:|&^@$]{1,2})/,
/(?<grp>[\[\]\(\)\",.])/,
/(?<nul>[ \t\n]+)/,
/(?<err>.)/,
],
'gi' // <= flags added to the entire regexp
)
console.log(regexp)
// => /(?<ids>[a-z_][a-z0-9_]*)|(?<num>\d+(\.\d*)?)|(?<ops>[-~+*/%=<>?!:|&^@$]{1,2})|(?<grp>[\[\]\(\)\",.])|(?<nul>[ \t\n]+)|(?<err>.)/gi
API
Table of Contents
joinRegExp
Utility to join RegExps together.
Parameters
regexps
Array<(RegExp | Array<RegExp>)> Array of regexps to be joined.flags
The flags to use (optional, default''
)
Contribute
All contributions are welcome!
License
MIT © 2021 stagas