join-regexp
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

join-regexp

utility to join regexps together

🔧 Install · 🧩 Example · 📜 API docs · 🔥 Releases · 💪🏼 Contribute · 🖐️ Help


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

  • regexps Array<(RegExp | Array<RegExp>)> Array of regexps to be joined.
  • flags The flags to use (optional, default '')

Contribute

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2021 stagas

Readme

Keywords

Package Sidebar

Install

npm i join-regexp

Weekly Downloads

7

Version

1.0.0

License

MIT

Unpacked Size

8.12 kB

Total Files

9

Last publish

Collaborators

  • stagas