0

I would like to define two regexs where the only difference is that one is global/multiline while the other is not.

How can I define them so that I don't have to repeat the full regex, i.e. use the first as a variable?

const regex1 = /(\[.*?\])/;
// const regex2 = /(\[.*?\])/gm;
const regex2 = regex1 + 'gm'; // error
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047

0 Answers0