helper.ts 256 B

12345678910
  1. export function combineRegex(strings: TemplateStringsArray, ...pieces: any[]) {
  2. return new RegExp(
  3. strings.raw
  4. .map(
  5. (r, i) =>
  6. r + (pieces[i] === undefined ? "" : "(?:" + pieces[i].source + ")")
  7. )
  8. .join("")
  9. );
  10. }