var str = "For more information, see Chapter 3.4.5.1";
var re = /(chapter \d+(\.\d)*)/i;
var found = str.match(re);
console.log(found);
捕获到了3个结果 : ["Chapter 3.4.5.1", "Chapter 3.4.5.1", ".1"]
而我认为结果应该只有一个 ["Chapter 3.4.5.1"],请问为什么会有3个?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
match的返回值包括分组匹配结果。https://developer.mozilla.org...