🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

regex-combiner

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regex-combiner

Combine multiple regexes into one

1.0.1
latest
Source
npm
Version published
Weekly downloads
7
-61.11%
Maintainers
1
Weekly downloads
 
Created
Source

Regex Combiner

Combines an array of regexes into a single regex.

Example

var regexCombiner = require('regex-combiner');
var combined = regexCombiner([
    /abc$/,
    /abcd+e/,
    /a.*/,
    /bar/,
    'bad+' // strings are accepted too
]);
/* /(a(bc($|d+e)|.*)|ba(r|d+))/ */

combined.test('abcdddde'); // true
combined.test('bar'); // true
combined.test('baddd'); // true

Caveats

  • No flags! Combining case-sensitive and case-insensitive regexes is ... difficult, so all flags are ignored.
  • No back-references in the input regexes. Things like /(['"])foo\1/ are just not going to work.
  • The resulting regex is pretty much only going to be useful for .test(). Trying to get something meaningful from the groups is not going to be fun.

Licence

MIT

Keywords

regex

FAQs

Package last updated on 08 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts