let a = "入数:40入;版本:普版" a = a .replace(new RegExp(';', 'ig'),";") .replace(new RegExp(':', 'ig'),":") .split(";"); [a[0],a[1]]=[a[1],a[0]];//通过数组解构来实现“不使用中间变量进行换值” console.log(a) console.log(a.join(";"))