Created
October 7, 2021 08:11
-
-
Save Blakeinstein/579dcbae697ed0cdfa96a0dd059a6f50 to your computer and use it in GitHub Desktop.
Concatinate multiple regexs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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