1.0.1 • Published 2 years ago

regexp-factorize v1.0.1

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

Regexp Factorize

install

npm i regexp-factorize

Sample

import { factorizeOr } from 'regexp-factorize';

const keywords = ['ant', 'antelope', 'albatross', 'alligator'];
const regexpString = factorizeOr(keywords); // a(?:nt(?:|elope)|l(?:batross|ligator))
const regexp = new RegExp(regexpString);

const document = "There's an alligator in my house";

console.log(regexp.test(document)); // true