const str = '3[dzl]2[xbb]' const name = str.match(/[*+]/) console.log(name) function repeat(name, num) { let result = '' for(let i = 0; i < num; i++) { result += name } return result }