【发布时间】:2019-05-02 21:25:16
【问题描述】:
代码sn-p
'a b'.match(/a|b/ig)
返回
["a", "b"]
这是完全可以预料的,因为我们正在搜索带有 'a' 或 'b' 的子字符串 但是为什么
'a b'.match(/(a|b)/i)
返回
["a", "a"]
作为输出,a 如何匹配两次?
不应该只是["a"]至于'a b'.match(/a|b/i)
【问题讨论】:
标签: javascript regex string string-matching regex-group