Skip to content

Instantly share code, notes, and snippets.

@Blakeinstein
Created October 7, 2021 08:11
Show Gist options
  • Save Blakeinstein/579dcbae697ed0cdfa96a0dd059a6f50 to your computer and use it in GitHub Desktop.
Save Blakeinstein/579dcbae697ed0cdfa96a0dd059a6f50 to your computer and use it in GitHub Desktop.
Concatinate multiple regexs
export const concatRegex = (...regexs: RegExp[]): RegExp => {
const flags = Array.from(
new Set<string>(
regexs.join().split('')
)
).join();
return new RegExp(regexs.reduce((a, b) => a + b.source, ''), flags);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment