var str = "总价为:1400.00元,单价为:200元" var matchResult = /总价为:([\d.]+?)元,单价为:([\d.]+?)元/.exec(str) if (matchResult) { let total = Number(matchResult[1]) let unit = Number(matchResult[2]) console.log(total, unit) }