regex-join

Merge multiple regexes and strings into one, preserving all the flags, automatically escaping the strings

Usage no npm install needed!

<script type="module">
  import regexJoin from 'https://cdn.skypack.dev/regex-join';
</script>

README

regex-join

Merge multiple regexes and strings into one, preserving all the flags, automatically escaping the strings

Install

npm install regex-join
const regexJoin = require('regex-join');

Usage

regexJoin(/^beginning/g, / (.+) end/);
// => /^beginning (.+) end/g
regexJoin('My (last) name is ', /(\w+)/g);
// => /My \(last\) name is (\w+)/g

API

regexJoin(part, part[, part,...])

Merges any number of RegExp or strings into one and returns a single RegExp

part

Type: RegExp | string

Related

  • one-event - Micro module to add an event listener to be executed only once.
  • select-dom - Lightweight querySelector/All wrapper that outputs an Array.
  • doma - Parse an HTML string into DocumentFragment or one Element, in a few bytes.
  • Refined GitHub - Uses this module.