需求:version = '1.0.0' 或者 version = '1.0.0.GA'
要得到:1.0.1 或者 1.0.1.GA
function up (versionString) {
let versionArray = versionString.split(".");
for (let i = versionArray.length - 1; i >= 0; i--) {
let versionChar = versionArray[i];
if (!isNaN(versionChar)) {
versionArray[i] = versionChar.replace(/.$/, versionChar[versionChar.length - 1] - 0 + 1);
break;
}
}
return versionArray.join(".");
}
let version = up("1.0.0")
console.log(version)
version = up("1.0.10")
console.log(version)
version = up("1.0.10.SNAPSHOT")
console.log(version)
version = up("SNAPSHOT")
console.log(version)
version = up("1.2.kk.3")
console.log(version)
version = up(".kk.")
console.log(version)
version = up(".kk")
console.log(version)