Skip to content

convert list of substring to match into factorized regexp

Notifications You must be signed in to change notification settings

apiculteur/regexp-factorize

Repository files navigation

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

About

convert list of substring to match into factorized regexp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published