let imageName = 'cbtmmprice'
let userID = 't03'
let matchReg = '^' + imageName + '-' + userID.toLowerCase() + '(-\\d+)?\\b'
let maxNum = 0
let newInstanceID = `${imageName}-${userID}`
const f1 = function(rsData){
for(let elem of rsData) {
let x = elem.InstanceID.match(matchReg)
console.log(x)
if (x !== null) {
if (x[1] !== undefined) {
let tempNum = Number(x[1].slice(1))
maxNum = Math.max(maxNum, tempNum)
newInstanceID = `${imageName}-${userID}-${maxNum + 1}`
}
}
}
}
let rsData=[{InstanceID:'cbtmmprice-t03'}]
f1(rsData)
console.log(newInstanceID)
console