1.0.0 • Published 2 years ago

join-regexp v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

src/index.ts:7-15

Utility to join RegExps together.

Parameters

Contribute

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2021 stagas