您可以使用以下方法检索这些match():const units = [ "Unit 1: First lesson", "Unit 2 and 3: Introduction", "Unit 4: Exercise", "Unit 5 and 6: Social Networking"];units.forEach(title => { // Only match on string before the ':' let unitNumbers = title.substr(0, title.indexOf(':')).match(/([0-9]+)/g); console.log(title, unitNumbers);});