任何人都可以告诉我为什么第二个片段在使用g旗帜时没有捕获'组' ?
"123".match(/(\d{1})(\d{1})/) // returns ["12", "1", "2"]
"123".match(/(\d{1})(\d{1})/g) // returns ["12"] (where's 1 and 2 ?)
Run Code Online (Sandbox Code Playgroud)
console.log("123".match(/(\d{1})(\d{1})/)) // returns ["12", "1", "2"]
console.log("123".match(/(\d{1})(\d{1})/g)) // returns ["12"] (where's 1 and 2 ?)Run Code Online (Sandbox Code Playgroud)