JS Store Regex en variable et combiner

const a = /a/
const b = /b/
// Concatenate two Regular Expressions with an OR |
const c = new RegExp( a.source + "|" + b.source );
// c --> /a|b/

"a".match(c)
// ["a", index: 0, input: "a", groups: undefined]
"b".match(c)
// ["b", index: 0, input: "b", groups: undefined]
"c".match(c)
// null
KostasX