RegExp composition

There was a fair amount of discussion related to this sort of idea in this thread: RegExp: Comments

One of the major hurdles is: How do you compose regular expression flags? Some flags just don't compose at all. Other flags do, but it would be nice if you're able to build the same regular expression without composing as you would build with composing.

In the end, the main differences between composing regular expressions, and composing strings that you pass into a regular expression constructor is this annoying flag situation, and verbosity.

For example, you can do this to achieve composition:

const part1 = String.raw`\d{3}`
const part2 = String.raw`\d{4}`

const pattern1 = new RegExp(part1)
const pattern2 = new RegExp(part2)
conts completePattern = new RegExp(`(${part1}) ${part1)-${part2}`)