📜  js 连接正则表达式 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:31.462000             🧑  作者: Mango

代码示例1
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